Beispiel #1
0
 /**
  * Get scripts and styles sources
  *
  * @since 2.7.7
  *
  * @param array|string $handles Registered script/style handle(s)
  * @param string       $type    js|css Defaults to 'js'
  * @param array        $_output Internal
  *
  * @return array Scripts/styles sources and status
  */
 function kc_get_sns($handles, $type = 'js', $_output = array())
 {
     if ($type == 'css') {
         global $wp_styles;
         $sources = $wp_styles;
     } else {
         global $wp_scripts;
         $sources = $wp_scripts;
     }
     foreach ((array) $handles as $id) {
         if (isset($_output[$id]) || !isset($sources->registered[$id])) {
             continue;
         }
         $src = $sources->registered[$id]->src;
         if (substr($sources->registered[$id]->src, 0, 1) === '/') {
             $src = site_url($src);
         }
         $_id = str_replace('-', '_', $id);
         $_output[$_id] = array('src' => $src, 'queue' => (int) wp_script_is($id));
         if (isset($sources->registered[$id]->extra['data'])) {
             $_output[$_id]['data'] = $sources->registered[$id]->extra['data'];
         }
         if (empty($sources->registered[$id]->deps)) {
             continue;
         }
         $_x = clone $sources;
         $_x->all_deps($id);
         if (!empty($_x->to_do)) {
             $_output[$_id]['deps'] = array_map('kc_get_sns_replacer', array_values($_x->to_do));
             $_output = kc_get_sns($sources->registered[$id]->deps, $type, $_output);
         }
     }
     return $_output;
 }
Beispiel #2
0
    public static function _sns_vars()
    {
        global $wp_scripts, $wp_locale;
        if (!in_array('kc-settings-base', $wp_scripts->in_footer)) {
            return;
        }
        $vars = array('locale' => get_locale(), 'paths' => self::$data['paths'], 'js' => kc_get_sns(array('jquery-ui-datepicker', 'thickbox', 'jquery-ui-sortable', 'chosen', 'wp-color-picker', 'kc-media-selector'), 'js'), 'css' => kc_get_sns(array('jquery-ui', 'thickbox', 'chosen', 'wp-color-picker'), 'css'), 'upload' => array('text' => array('head' => 'KC Settings', 'empty' => __('Please upload some files and then go back to this tab.', 'kc-settings'), 'checkAll' => __('Select all files', 'kc-settings'), 'clear' => __('Clear selections', 'kc-settings'), 'invert' => __('Invert selection', 'kc-settings'), 'addFiles' => __('Add files to collection', 'kc-settings'), 'info' => __('Click the "Media Library" tab to insert files that are already upload, or, upload your files and then go to the "Media Library" tab to insert the files you just uploaded.', 'kc-settings'), 'selFile' => __('Select file', 'kc-settings'), 'filenomatch' => __("You can't select this because the file type doesn't match", 'kc-settings'))), 'texts' => array('show' => __('Show', 'kc-settings'), 'hide' => __('Hide', 'kc-settings'), 'now' => __('Now', 'kc-settings'), 'done' => __('Done', 'kc-settings'), 'time' => __('Time', 'kc-settings'), 'hour' => __('Hour', 'kc-settings'), 'minute' => __('Minute', 'kc-settings'), 'today' => __('Today', 'kc-settings'), 'prev' => __('Prev', 'kc-settings'), 'next' => __('Next', 'kc-settings'), 'chooseTime' => __('Choose time', 'kc-settings'), 'monthNames' => array('full' => $wp_locale->month, 'shrt' => $wp_locale->month_abbrev), 'dayNames' => array('full' => $wp_locale->weekday, 'shrt' => $wp_locale->weekday_abbrev, 'min' => array(_x('Su', 'day min name', 'kc-settings'), _x('Mo', 'day min name', 'kc-settings'), _x('Tu', 'day min name', 'kc-settings'), _x('We', 'day min name', 'kc-settings'), _x('Th', 'day min name', 'kc-settings'), _x('Fr', 'day min name', 'kc-settings'), _x('Sa', 'day min name', 'kc-settings'))), 'weekNames' => array('full' => __('Week', 'kc-settings'), 'shrt' => _x('Wk', 'week short', 'kc-settings'))), 'mediaFields' => self::$data['media_fields']);
        ?>
<script>
  var kcSettings = <?php 
        echo json_encode($vars);
        ?>
</script>
<?php 
    }