当前位置: 首页>>代码示例>>PHP>>正文


PHP Redux_Helpers::curlRead方法代码示例

本文整理汇总了PHP中Redux_Helpers::curlRead方法的典型用法代码示例。如果您正苦于以下问题:PHP Redux_Helpers::curlRead方法的具体用法?PHP Redux_Helpers::curlRead怎么用?PHP Redux_Helpers::curlRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redux_Helpers的用法示例。


在下文中一共展示了Redux_Helpers::curlRead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getGoogleArray

 /**
  *
  *   Construct the google array from the stored JSON/HTML
  *
  */
 function getGoogleArray()
 {
     global $wp_filesystem;
     if (isset($this->parent->fonts['google']) && !empty($this->parent->fonts['google'])) {
         return;
     }
     if (isset($this->field['update_weekly']) && $this->field['update_weekly'] === true && $this->field['google'] === true && !empty($this->parent->args['google_api_key'])) {
         //if (file_exists(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.html')) {
         if (file_exists($this->google_html)) {
             // Keep the fonts updated weekly
             $weekback = strtotime(date('jS F Y', time() + 60 * 60 * 24 * -7));
             //$last_updated = filemtime(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.html');
             $last_updated = filemtime($this->google_html);
             if ($last_updated < $weekback) {
                 //unlink(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.html');
                 unlink($this->google_html);
                 //unlink(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.json');
                 unlink($this->google_json);
             }
         }
     }
     // Initialize the Wordpress filesystem, no more using file_put_contents function
     if (empty($wp_filesystem)) {
         require_once ABSPATH . '/wp-admin/includes/file.php';
         WP_Filesystem();
     }
     //if (!file_exists(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.json')) {
     if (!file_exists($this->google_json)) {
         $result = wp_remote_get(apply_filters('redux-google-fonts-api-url', 'https://www.googleapis.com/webfonts/v1/webfonts?key=') . $this->parent->args['google_api_key'], array('sslverify' => false));
         if (!is_wp_error($result) && $result['response']['code'] == 200) {
             $result = json_decode($result['body']);
             foreach ($result->items as $font) {
                 $this->parent->googleArray[$font->family] = array('variants' => $this->getVariants($font->variants), 'subsets' => $this->getSubsets($font->subsets));
             }
             if (!empty($this->parent->googleArray)) {
                 //$wp_filesystem->put_contents(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.json', json_encode($this->parent->googleArray), FS_CHMOD_FILE
                 $wp_filesystem->put_contents($this->google_json, json_encode($this->parent->googleArray), FS_CHMOD_FILE);
             }
         }
         //if
     }
     //if
     if (!isset($this->parent->fonts['google']) || empty($this->parent->fonts['google'])) {
         //$fonts = json_decode($wp_filesystem->get_contents(ReduxFramework::$_dir . 'inc/fields/typography/googlefonts.json'), true);
         $fonts = json_decode($wp_filesystem->get_contents($this->google_json), true);
         // Fallback if file_get_contents won't work for wordpress. MEDIATEMPLE
         if (empty($fonts)) {
             $fonts = Redux_Helpers::curlRead($this->google_json);
         }
         if (isset($fonts) && !empty($fonts) && is_array($fonts) && $fonts != false) {
             $this->parent->fonts['google'] = $fonts;
             $this->parent->font_groups['google'] = array('id' => 'google', 'text' => __('Google Webfonts', 'redux-framework'), 'children' => array());
             foreach ($this->parent->fonts['google'] as $font => $extra) {
                 $this->parent->font_groups['google']['children'][] = array('id' => $font, 'text' => $font);
             }
         }
     }
 }
开发者ID:EmreKarahan,项目名称:wordpress,代码行数:63,代码来源:field_typography.php

示例2: getGoogleArray

 /**
  *
  *   Construct the google array from the stored JSON/HTML
  *
  */
 function getGoogleArray()
 {
     global $wp_filesystem;
     // Is already present?
     if (isset($this->parent->fonts['google']) && !empty($this->parent->fonts['google'])) {
         return;
     }
     // Weekly update
     if (isset($this->field['update_weekly']) && $this->field['update_weekly'] === true && $this->field['google'] === true && !empty($this->parent->args['google_api_key'])) {
         if (file_exists($this->google_json)) {
             // Keep the fonts updated weekly
             $weekback = strtotime(date('jS F Y', time() + 60 * 60 * 24 * -7));
             $last_updated = filemtime($this->google_json);
             if ($last_updated < $weekback) {
                 unlink($this->google_json);
             }
         }
     }
     // Initialize the Wordpress filesystem, no more using file_put_contents function
     Redux_Functions::initWpFilesystem();
     if (!file_exists($this->google_json)) {
         $result = wp_remote_get(apply_filters('redux-google-fonts-api-url', 'https://www.googleapis.com/webfonts/v1/webfonts?key=') . $this->parent->args['google_api_key'], array('sslverify' => false));
         if (!is_wp_error($result) && $result['response']['code'] == 200) {
             $result = json_decode($result['body']);
             foreach ($result->items as $font) {
                 $this->parent->googleArray[$font->family] = array('variants' => $this->getVariants($font->variants), 'subsets' => $this->getSubsets($font->subsets));
             }
             if (!empty($this->parent->googleArray)) {
                 $wp_filesystem->put_contents($this->google_json, json_encode($this->parent->googleArray), FS_CHMOD_FILE);
             }
         }
         //if
     }
     if (!isset($this->parent->fonts['google']) || empty($this->parent->fonts['google'])) {
         $fonts = json_decode($wp_filesystem->get_contents($this->google_json), true);
         // Fallback if file_get_contents won't work for wordpress. MEDIATEMPLE
         if (empty($fonts)) {
             $fonts = Redux_Helpers::curlRead($this->google_json);
         }
         if (isset($fonts) && !empty($fonts) && is_array($fonts) && $fonts != false) {
             $this->parent->fonts['google'] = $fonts;
             $this->parent->googleArray = $fonts;
             // optgroup
             $this->parent->font_groups['google'] = array('text' => __('Google Webfonts', 'redux-framework'), 'children' => array());
             // options
             foreach ($this->parent->fonts['google'] as $font => $extra) {
                 $this->parent->font_groups['google']['children'][] = array('id' => $font, 'text' => $font, 'data-google' => 'true');
             }
         }
     }
 }
开发者ID:Ahmed-dawoud,项目名称:care4u,代码行数:56,代码来源:field_typography.php


注:本文中的Redux_Helpers::curlRead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。