/**
  * You may set the pager configuration value to either page or paged to
  * switch the pagination from showing post listings to showing post
  * segments.
  *
  * @param mixed query
  * @param array configuration
  */
 function __construct($query, $conf = null)
 {
     if ($conf === null) {
         $conf = array();
     }
     $this->query = $query;
     $config = wpgrade::config();
     $config_defaults = $config['pagination'];
     // the pager determines what we're paginating (ie. "paged" for listing
     // of posts, and "page" for post parts)
     if (isset($conf['pager'])) {
         $this->pager = $conf['pager'];
     } else {
         if (isset($config_defaults['pager'])) {
             $this->pager = $config_defaults['pager'];
         } else {
             // no pager configuration entry
             // fallback to listing pagination
             if (is_front_page() && is_page()) {
                 $this->pager = 'page';
             } else {
                 $this->pager = 'paged';
             }
         }
     }
     $this->conf = wpgrade::merge($config_defaults, $conf);
 }
Пример #2
0
function wpgrade_callback_enqueue_theme_resources()
{
    $themeconfiguration = wpgrade::config();
    // Scripts registers, localization and enqueues
    // --------------------------------------------
    // auto-enqueue
    foreach ($themeconfiguration['resources']['auto-enqueue-scripts'] as $stylename) {
        wp_enqueue_script($stylename);
    }
    // auto-localize
    foreach ($themeconfiguration['resources']['auto-localize-scripts'] as $stylename => $script) {
        // allow child themes to remove the localization
        if ($script !== null) {
            // localize the theme_name, we are gonna need it
            if ($stylename === 'wpgrade-main-scripts') {
                $script['theme_name'] = wpgrade::shortname();
            }
            foreach ($script as $key => $data) {
                wp_localize_script($stylename, $key, $data);
            }
        }
    }
    // Style registers and enqueues
    // ----------------------------
    // auto-enqueue registered styles
    foreach ($themeconfiguration['resources']['auto-enqueue-styles'] as $stylename) {
        wp_enqueue_style($stylename);
    }
}
Пример #3
0
 static function instance($reinitialize = false)
 {
     if (self::$instance == null || $reinitialize) {
         $config = wpgrade::config();
         self::$instance = new WPGradeOptions($config['theme-options']);
     }
     return self::$instance;
 }
Пример #4
0
// Dynamically load in all classes
// -------------------------------
# Loading convention: if it's a PHP file it's loaded, the shorter the path
# the higher the priority
$classpath = $basepath . 'classes' . DIRECTORY_SEPARATOR;
wpgrade::require_all($classpath);
// Setup Option Drivers
// --------------------
if (wpgrade::confoption('wpml_separate_options', false)) {
    $wpgrade_redux = new wpGrade_Redux();
}
// the handler is the main object responsible for managing the drivers
wpgrade::options_handler(new WPGradeOptions());
# [!!] driver priority works like a LIFO stack, last in = highest priority
// register basic configuration driver
$config = wpgrade::config();
wpgrade::options()->add_optiondriver(new WPGradeOptionDriver_Config($config['theme-options']));
// we register redux as option driver via a resolver
function wpgrade_callback_bootstrap_redux_instance($redux)
{
    $reduxdriver = new WPGradeOptionDriver_Redux($redux);
    wpgrade::options()->add_optiondriver($reduxdriver);
}
wpgrade::register_resolver('redux-instance', 'wpgrade_callback_bootstrap_redux_instance');
// Plugins & Resolvable Dependencies
// ---------------------------------
require wpgrade::themefilepath(wpgrade::confoption('theme-adminpanel-path', 'theme-content/admin-panel') . '/bootstrap' . EXT);
// Hooks
// -----
get_template_part('wpgrade-core/hooks');
// Upgrade Notifier
Пример #5
0
/**
 * ...
 */
function wpgrade_callbacks_setup_shortcodes_plugin()
{
    $current_options = get_option('wpgrade_shortcodes_list');
    $config = wpgrade::config();
    $shortcodes = $config['shortcodes'];
    // create an array with shortcodes which are needed by the
    // current theme
    if ($current_options) {
        $diff_added = array_diff($shortcodes, $current_options);
        $diff_removed = array_diff($current_options, $shortcodes);
        if ((!empty($diff_added) || !empty($diff_removed)) && is_admin()) {
            update_option('wpgrade_shortcodes_list', $shortcodes);
        }
    } else {
        // there is no current shortcodes list
        update_option('wpgrade_shortcodes_list', $shortcodes);
    }
    // we need to remember the prefix of the metaboxes so it can be used
    // by the shortcodes plugin
    $current_prefix = get_option('wpgrade_metaboxes_prefix');
    if (empty($current_prefix)) {
        update_option('wpgrade_metaboxes_prefix', wpgrade::prefix());
    }
}