コード例 #1
0
 /**
  * Register/queue frontend scripts.
  *
  * @access public
  * @return void
  * @todo include script_debug mode $min
  * @todo conditionally load on the specific recipe hero pages
  */
 public function load_scripts()
 {
     // Register all scripts/styles for later use
     wp_register_script('numeric', RH()->plugin_url() . '/assets/admin/js/jquery.numeric.js', array('jquery'), RecipeHero::$version, true);
     wp_register_script('liquidmetal', RH()->plugin_url() . '/assets/admin/js/liquidmetal.js', array('jquery'), RecipeHero::$version, true);
     wp_register_script('recipe-ordering', RH()->plugin_url() . '/assets/admin/js/recipe-ordering.js', array('jquery', 'jquery-ui-sortable'), RecipeHero::$version, true);
     wp_register_script('rh-admin-meta-boxes-gallery', RH()->plugin_url() . '/assets/admin/js/meta-boxes-gallery.js', array('jquery', 'jquery-ui-sortable', 'tiptip'), RecipeHero::$version, true);
     wp_register_script('tiptip', RH()->plugin_url() . '/assets/admin/js/jquery-tiptip/jquery.tipTip.min.js', array('jquery'), RecipeHero::$version, true);
     wp_register_style('tiptip-css', RH()->plugin_url() . '/assets/admin/css/tiptip.css');
     wp_register_script('select2', RH()->plugin_url() . '/assets/admin/js/jquery-select/select2.min.js', array('jquery'), RecipeHero::$version, true);
     wp_register_style('select2-css', RH()->plugin_url() . '/assets/admin/css/select2.css');
     wp_register_script('rh-admin-js', RH()->plugin_url() . '/assets/admin/js/admin.js', array('jquery', 'numeric', 'liquidmetal', 'tiptip', 'select2'), RecipeHero::$version, true);
     wp_register_style('rh-admin-css', RH()->plugin_url() . '/assets/admin/css/admin.css');
     wp_enqueue_script('jquery');
     wp_enqueue_script('numeric');
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-autocomplete');
     wp_enqueue_script('liquidmetal');
     wp_enqueue_style('wp-color-picker');
     wp_enqueue_script('tiptip');
     wp_enqueue_style('tiptip-css');
     wp_enqueue_script('select2');
     wp_enqueue_style('select2-css');
     wp_enqueue_script('rh-admin-js');
     wp_enqueue_style('rh-admin-css');
     wp_enqueue_script('rh-admin-meta-boxes-gallery');
 }
コード例 #2
0
 /**
  * when we load up our posts query, if we're actually sorting by menu order, initialize sorting scripts
  */
 public static function wp()
 {
     $orderby = get_query_var('orderby');
     if (is_string($orderby) && 0 === strpos($orderby, 'menu_order') || isset($orderby['menu_order']) && $orderby['menu_order'] == 'ASC') {
         wp_register_script('recipe-ordering', RH()->plugin_url() . '/assets/admin/js/recipe-ordering.js', array('jquery', 'jquery-ui-sortable'), RecipeHero::$version, true);
         wp_enqueue_script('recipe-ordering');
     }
 }
コード例 #3
0
 /**
  * Output the settings
  */
 public function output()
 {
     global $current_section;
     $integrations = RH()->integrations->get_integrations();
     if (isset($integrations[$current_section])) {
         $integrations[$current_section]->admin_options();
     }
 }
コード例 #4
0
 /**
  * Register/queue frontend scripts.
  *
  * @access public
  * @return void
  */
 public function load_scripts()
 {
     global $post, $wp;
     // Register all scripts/styles for later use
     wp_register_script('rh-scripts', RH()->plugin_url() . '/assets/frontend/js/rh-scripts.js', array('jquery'), RecipeHero::$version, true);
     wp_register_script('magnific', RH()->plugin_url() . '/assets/frontend/js/jquery.magnific-popup.min.js', array('jquery'), RecipeHero::$version, true);
     wp_register_script('rh-lightbox', RH()->plugin_url() . '/assets/frontend/js/rh-lightbox.js', array('jquery', 'magnific'), RecipeHero::$version, true);
     wp_register_style('magnific-css', RH()->plugin_url() . '/assets/frontend/css/magnific-popup.css', RecipeHero::$version, true);
     wp_register_style('rh-general-rtl', RH()->plugin_url() . '/assets/frontend/css/recipe-hero-rtl.css', RecipeHero::$version, true);
     if (is_rtl()) {
         wp_enqueue_style('rh-general-rtl');
     }
     wp_enqueue_script('jquery');
     wp_enqueue_script('rh-scripts');
     // CSS Styles
     wp_enqueue_style('dashicons');
     $enqueue_styles = $this->get_styles();
     if ($enqueue_styles) {
         foreach ($enqueue_styles as $handle => $args) {
             wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
コード例 #5
0
ファイル: class-rh-admin.php プロジェクト: emzo/Recipe-Hero
 /**
  * Register and enqueue admin-specific JavaScript.
  *
  * @since     0.5.0
  *
  * @return    null    Return early if no settings page is registered.
  */
 public function enqueue_admin_scripts()
 {
     if (!isset($this->plugin_screen_hook_suffix)) {
         return;
     }
     $screen = get_current_screen();
     if ($this->plugin_screen_hook_suffix == $screen->id) {
         wp_enqueue_script($this->plugin_slug . '-admin-script', RH()->plugin_url() . '/assets/admin/js/admin.js', array('jquery'), Recipe_Hero::VERSION);
     }
 }
コード例 #6
0
ファイル: cmb2-select2.php プロジェクト: emzo/Recipe-Hero
<?php

// Useful global constants
define('PW_SELECT2_URL', RH()->plugin_url() . '/includes/fields/custom/cmb2-select2/');
/**
 * Enqueue scripts and styles, call requested select box field
 */
function pw_select2($field, $meta)
{
    wp_enqueue_script('pw-select2-field-init', PW_SELECT2_URL . 'cmb2-select2-js.js', array('select2'), null);
    wp_enqueue_style('pw-select2-field-mods', PW_SELECT2_URL . 'cmb2-select2-css.css', array(), null);
    call_user_func($field->args('type'), $field->args(), $meta);
    $desc = $field->args('desc');
    echo !empty($desc) && !empty($meta) ? '<p class="cmb2-metabox-description">' . $desc . '</p>' : '';
}
add_filter('cmb2_render_pw_select', 'pw_select2', 10, 2);
add_filter('cmb2_render_pw_multiselect', 'pw_select2', 10, 2);
/**
 * Render select box field
 */
function pw_select($field, $meta)
{
    echo '<select name="', $field['id'], '" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
    if (isset($field['options']) && !empty($field['options'])) {
        foreach ($field['options'] as $option_key => $option) {
            $opt_label = is_array($option) && array_key_exists('name', $option) ? $option['name'] : $option;
            $opt_value = is_array($option) && array_key_exists('value', $option) ? $option['value'] : $option_key;
            echo '<option value="', $opt_value, '" ', selected($meta == $opt_value), '>', $opt_label, '</option>';
        }
    }
    echo '</select>';
コード例 #7
0
ファイル: recipe-hero.php プロジェクト: emzo/Recipe-Hero
         *
         * @return string
         */
        public function plugin_path()
        {
            return untrailingslashit(plugin_dir_path(__FILE__));
        }
        /**
         * Get the template path.
         *
         * @return string
         */
        public function template_path()
        {
            return apply_filters('recipe_hero_template_path', 'recipe-hero/');
        }
    }
}
/**
 * Returns the main instance of RecipeHero to prevent the need to use globals.
 *
 * @since  1.0.0
 * @return RecipeHero (Class)
 */
function RH()
{
    return RecipeHero::instance();
}
// Global for backwards compatibility.
$GLOBALS['recipe_hero'] = RH();
コード例 #8
0
    exit;
}
// Exit if accessed directly
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function rh_template_redirect()
{
    // When default permalinks are enabled, redirect recipes page to post type archive url
    if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == rh_get_page_id('recipes')) {
        wp_safe_redirect(get_post_type_archive_link('recipe'));
        exit;
    }
}
add_action('template_redirect', 'rh_template_redirect');
/**
 * Include all the template parts
 *
 * @package   Recipe Hero
 * @author    Captain Theme <*****@*****.**>
 * @since 	  1.0.2
 */
require_once RH()->plugin_path() . '/includes/templates-parts/rh-templates-archive-functions.php';
require_once RH()->plugin_path() . '/includes/templates-parts/rh-templates-search-functions.php';
require_once RH()->plugin_path() . '/includes/templates-parts/rh-templates-sidebar-functions.php';
require_once RH()->plugin_path() . '/includes/templates-parts/rh-templates-single-functions.php';
require_once RH()->plugin_path() . '/includes/templates-parts/rh-templates-supports-functions.php';
require_once RH()->plugin_path() . '/includes/templates-parts/rh-templates-wrapper-functions.php';
コード例 #9
0
ファイル: rh-templates.php プロジェクト: emzo/Recipe-Hero
 function recipe_hero_locate_template($template_name, $template_path = '', $default_path = '')
 {
     if (!$template_path) {
         $template_path = RH()->template_path();
     }
     if (!$default_path) {
         $default_path = RH()->plugin_path() . '/templates/';
     }
     // Look within passed path within the theme - this is priority
     $template = locate_template(array(trailingslashit($template_path) . $template_name, $template_name));
     // Get default template
     if (!$template) {
         $template = $default_path . $template_name;
     }
     // Return what we found
     return apply_filters('recipe_hero_locate_template', $template, $template_name, $template_path);
 }
コード例 #10
0
 /**
  * Helper function to get the formated description and tip HTML for a
  * given form field. Plugins can call this when implementing their own custom
  * settings types.
  *
  * @param array $value The form field value array
  * @returns array The description and tip as a 2 element array
  */
 public static function get_field_description($value)
 {
     $description = '';
     $tooltip_html = '';
     if (true === $value['desc_tip']) {
         $tooltip_html = $value['desc'];
     } elseif (!empty($value['desc_tip'])) {
         $description = $value['desc'];
         $tooltip_html = $value['desc_tip'];
     } elseif (!empty($value['desc'])) {
         $description = $value['desc'];
     }
     if ($description && in_array($value['type'], array('textarea', 'radio'))) {
         $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>';
     } elseif ($description && in_array($value['type'], array('checkbox'))) {
         $description = wp_kses_post($description);
     } elseif ($description) {
         $description = '<span class="description">' . wp_kses_post($description) . '</span>';
     }
     if ($tooltip_html && in_array($value['type'], array('checkbox'))) {
         $tooltip_html = '<p class="description">' . $tooltip_html . '</p>';
     } elseif ($tooltip_html) {
         $tooltip_html = '<img class="help_tip" data-tip="' . esc_attr($tooltip_html) . '" src="' . RH()->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
     }
     return array('description' => $description, 'tooltip_html' => $tooltip_html);
 }
コード例 #11
0
 /**
  * Get HTML for tooltips
  *
  * @param  array $data
  * @return string
  */
 public function get_tooltip_html($data)
 {
     if ($data['desc_tip'] === true) {
         $tip = $data['description'];
     } elseif (!empty($data['desc_tip'])) {
         $tip = $data['desc_tip'];
     } else {
         $tip = '';
     }
     return $tip ? '<img class="help_tip" data-tip="' . esc_attr($tip) . '" src="' . RH()->plugin_url() . '/assets/images/help.png" height="16" width="16" />' : '';
 }