public function __construct($parent) { $this->parent = $parent; Redux_Functions::$_parent = $parent; $this->min = Redux_Functions::isMin(); $this->timestamp = ReduxFramework::$_version; if ($parent->args['dev_mode']) { $this->timestamp .= '.' . time(); } $this->register_styles(); $this->register_scripts(); add_thickbox(); $this->enqueue_fields(); $this->set_localized_data(); /** * action 'redux-enqueue-{opt_name}' * * @deprecated * * @param object $this ReduxFramework */ do_action("redux-enqueue-{$parent->args['opt_name']}", $parent); // REMOVE /** * action 'redux/page/{opt_name}/enqueue' */ do_action("redux/page/{$parent->args['opt_name']}/enqueue"); }
public function __construct($parent) { $this->parent = $parent; Redux_Functions::$_parent = $parent; $this->template_path = $this->original_path = ReduxFramework::$_dir . 'templates/panel/'; $this->template_path = trailingslashit(apply_filters("redux/{$this->parent->args['opt_name']}/panel/templates_path", $this->template_path)); $this->panel_template(); }
public function __construct($parent) { $this->parent = $parent; Redux_Functions::$_parent = $parent; /** * action 'redux/page/{opt_name}/' */ do_action("redux/page/{$parent->args['opt_name']}/"); }
public function __construct($parent) { $this->parent = $parent; Redux_Functions::$_parent = $parent; }
/** * Class Constructor. Defines the args for the theme options class * * @since 1.0.0 * * @param array $sections Panel sections. * @param array $args Class constructor arguments. * @param array $extra_tabs Extra panel tabs. // REMOVE * * @return \ReduxFramework */ public function __construct($sections = array(), $args = array(), $extra_tabs = array()) { // Disregard WP AJAX 'heartbeat'call. Why waste resources? if (isset($_POST) && isset($_POST['action']) && $_POST['action'] == 'heartbeat') { // Hook, for purists. if (!has_action('redux/ajax/heartbeat')) { do_action('redux/ajax/heartbeat', $this); } // Buh bye! return; } // Pass parent pointer to function helper. Redux_Functions::$_parent = $this; // Set values $this->set_default_args(); $this->args = wp_parse_args($args, $this->args); if (empty($this->args['transient_time'])) { $this->args['transient_time'] = 60 * MINUTE_IN_SECONDS; } if (empty($this->args['footer_credit'])) { $this->args['footer_credit'] = '<span id="footer-thankyou">' . sprintf(__('Options panel created using %1$s', 'redux-framework'), '<a href="' . esc_url($this->framework_url) . '" target="_blank">' . __('Redux Framework', 'redux-framework') . '</a> v' . self::$_version) . '</span>'; } if (empty($this->args['menu_title'])) { $this->args['menu_title'] = __('Options', 'redux-framework'); } if (empty($this->args['page_title'])) { $this->args['page_title'] = __('Options', 'redux-framework'); } /** * filter 'redux/args/{opt_name}' * * @param array $args ReduxFramework configuration */ $this->args = apply_filters("redux/args/{$this->args['opt_name']}", $this->args); /** * filter 'redux/options/{opt_name}/args' * * @param array $args ReduxFramework configuration */ $this->args = apply_filters("redux/options/{$this->args['opt_name']}/args", $this->args); // Do not save the defaults if we're on a live preview! if ($GLOBALS['pagenow'] == "customize" && isset($_GET['theme']) && !empty($_GET['theme'])) { $this->args['save_defaults'] = false; } if (!empty($this->args['opt_name'])) { /** * SHIM SECTION * Old variables and ways of doing things that need correcting. ;) * */ // Variable name change if (!empty($this->args['page_cap'])) { $this->args['page_permissions'] = $this->args['page_cap']; unset($this->args['page_cap']); } if (!empty($this->args['page_position'])) { $this->args['page_priority'] = $this->args['page_position']; unset($this->args['page_position']); } if (!empty($this->args['page_type'])) { $this->args['menu_type'] = $this->args['page_type']; unset($this->args['page_type']); } // Get rid of extra_tabs! Not needed. if (is_array($extra_tabs) && !empty($extra_tabs)) { foreach ($extra_tabs as $tab) { array_push($this->sections, $tab); } } // Move to the first loop area! /** * filter 'redux-sections' * * @deprecated * * @param array $sections field option sections */ $this->sections = apply_filters('redux-sections', $sections); // REMOVE LATER /** * filter 'redux-sections-{opt_name}' * * @deprecated * * @param array $sections field option sections */ $this->sections = apply_filters("redux-sections-{$this->args['opt_name']}", $this->sections); // REMOVE LATER /** * filter 'redux/options/{opt_name}/sections' * * @param array $sections field option sections */ $this->sections = apply_filters("redux/options/{$this->args['opt_name']}/sections", $this->sections); /** * Construct hook * action 'redux/construct' * * @param object $this ReduxFramework */ do_action('redux/construct', $this); // Set the default values $this->_default_cleanup(); // Internataionalization $this->_internationalization(); $this->filesystem = new Redux_Filesystem($this); //set redux upload folder $this->set_redux_content(); // Register extra extensions $this->_register_extensions(); // Grab database values $this->get_options(); // Options page add_action('admin_menu', array($this, '_options_page')); // Add a network menu if ($this->args['database'] == "network" && $this->args['network_admin']) { add_action('network_admin_menu', array($this, '_options_page')); } // Admin Bar menu add_action('admin_bar_menu', array($this, '_admin_bar_menu'), $this->args['admin_bar_priority']); // Register setting add_action('admin_init', array($this, '_register_settings')); // Display admin notices in dev_mode if (true == $this->args['dev_mode']) { require_once self::$_dir . 'inc/debug.php'; $this->debug = new ReduxDebugObject($this); if (true == $this->args['update_notice']) { add_action('admin_init', array($this, '_update_check')); } } // Display admin notices add_action('admin_notices', array($this, '_admin_notices'), 99); // Check for dismissed admin notices. add_action('admin_init', array($this, '_dismiss_admin_notice'), 9); // Enqueue the admin page CSS and JS if (isset($_GET['page']) && $_GET['page'] == $this->args['page_slug']) { add_action('admin_enqueue_scripts', array($this, '_enqueue'), 1); } // Output dynamic CSS // Frontend: Maybe enqueue dynamic CSS and Google fonts if (empty($this->args['output_location']) || in_array('frontend', $this->args['output_location'])) { add_action('wp_head', array(&$this, '_output_css'), 150); add_action('wp_enqueue_scripts', array(&$this, '_enqueue_output'), 150); } // Login page: Maybe enqueue dynamic CSS and Google fonts if (in_array('login', $this->args['output_location'])) { add_action('login_head', array(&$this, '_output_css'), 150); add_action('login_enqueue_scripts', array(&$this, '_enqueue_output'), 150); } // Admin area: Maybe enqueue dynamic CSS and Google fonts if (in_array('admin', $this->args['output_location'])) { add_action('admin_head', array(&$this, '_output_css'), 150); add_action('admin_enqueue_scripts', array(&$this, '_enqueue_output'), 150); } add_action('wp_print_scripts', array($this, 'vc_fixes'), 100); add_action('admin_enqueue_scripts', array($this, 'vc_fixes'), 100); if ($this->args['database'] == "network" && $this->args['network_admin']) { add_action('network_admin_edit_redux_' . $this->args['opt_name'], array($this, 'save_network_page'), 10, 0); add_action('admin_bar_menu', array($this, 'network_admin_bar'), 999); } // Ajax saving!!! add_action("wp_ajax_" . $this->args['opt_name'] . '_ajax_save', array($this, "ajax_save")); } /** * Loaded hook * action 'redux/loaded' * * @param object $this ReduxFramework */ do_action('redux/loaded', $this); }
/** * Enqueue CSS/JS for options page * * @since 1.0.0 * @access public * @global $wp_styles * @return void */ public function _enqueue() { global $wp_styles; Redux_Functions::$_parent = $this; $min = Redux_Functions::isMin(); // Select2 business. Fields: Background, Border, Dimensions, Select, Slider, Typography $field_arr = array('background', 'border', 'dimensions', 'select', 'select_image', 'slider', 'spacing', 'typography', 'color_scheme', 'css_layout'); if (Redux_Helpers::isFieldInUseByType($this->fields, $field_arr)) { // select2 CSS wp_register_style('select2-css', self::$_url . 'assets/js/vendor/select2/select2.css', array(), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.css'), 'all'); wp_enqueue_style('select2-css'); // JS wp_register_script('redux-select2-sortable-js', self::$_url . 'assets/js/vendor/redux.select2.sortable' . $min . '.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor/redux.select2.sortable' . $min . '.js'), true); wp_register_script('select2-js', self::$_url . 'assets/js/vendor/select2/select2.min.js', array('jquery', 'redux-select2-sortable-js'), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.min.js'), true); wp_enqueue_script('select2-js'); } redux_enqueue_style($this, 'redux-admin-css', self::$_url . 'assets/css/redux-admin.css', self::$_dir . 'assets/css/', array('farbtastic'), time(), 'all'); // wp_enqueue_style( // 'redux-css', // self::$_url . 'assets/css/redux.css', // array( 'farbtastic' ), // filemtime( self::$_dir . 'assets/css/redux.css' ), // 'all' // ); // // wp_register_style( // 'admin-css', // self::$_url . 'assets/css/admin.css', // array( 'farbtastic' ), // filemtime( self::$_dir . 'assets/css/admin.css' ), // 'all' // ); wp_register_style('redux-elusive-icon', self::$_url . 'assets/css/vendor/elusive-icons/elusive-webfont.css', array(), filemtime(self::$_dir . 'assets/css/vendor/elusive-icons/elusive-webfont.css'), 'all'); wp_register_style('redux-elusive-icon-ie7', self::$_url . 'assets/css/vendor/elusive-icons/elusive-webfont-ie7.css', array(), filemtime(self::$_dir . 'assets/css/vendor/elusive-icons/elusive-webfont-ie7.css'), 'all'); wp_register_style('qtip-css', self::$_url . 'assets/css/vendor/qtip/jquery.qtip.css', array(), filemtime(self::$_dir . 'assets/css/vendor/qtip/jquery.qtip.css'), 'all'); $wp_styles->add_data('redux-elusive-icon-ie7', 'conditional', 'lte IE 7'); /** * jQuery UI stylesheet src * filter 'redux/page/{opt_name}/enqueue/jquery-ui-css' * * @param string bundled stylesheet src */ wp_register_style('jquery-ui-css', apply_filters("redux/page/{$this->args['opt_name']}/enqueue/jquery-ui-css", self::$_url . 'assets/css/vendor/jquery-ui-bootstrap/jquery-ui-1.10.0.custom.css'), '', filemtime(self::$_dir . 'assets/css/vendor/jquery-ui-bootstrap/jquery-ui-1.10.0.custom.css'), 'all'); wp_enqueue_style('jquery-ui-css'); wp_enqueue_style('redux-lte-ie8'); wp_enqueue_style('qtip-css'); wp_enqueue_style('redux-elusive-icon'); wp_enqueue_style('redux-elusive-icon-ie7'); if (is_rtl()) { wp_register_style('redux-rtl-css', self::$_url . 'assets/css/rtl.css', array('redux-css'), filemtime(self::$_dir . 'assets/css/rtl.css'), 'all'); wp_enqueue_style('redux-rtl-css'); } wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-dialog'); // Load jQuery sortable for slides, sorter, sortable and group if (Redux_Helpers::isFieldInUseByType($this->fields, array('slides', 'sorter', 'sortable', 'group'))) { wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_style('jquery-ui-sortable'); } // Load jQuery UI Datepicker for date if (Redux_Helpers::isFieldInUseByType($this->fields, array('date', 'datetime'))) { wp_enqueue_script('jquery-ui-datepicker'); } // Load jQuery UI Accordion for slides and group if (Redux_Helpers::isFieldInUseByType($this->fields, array('slides', 'group'))) { wp_enqueue_script('jquery-ui-accordion'); } // Load wp-color-picker for color, color_gradient, link_color, border, background and typography if (Redux_Helpers::isFieldInUseByType($this->fields, array('background', 'color', 'color_gradient', 'link_color', 'border', 'typography', 'css_layout'))) { redux_enqueue_style($this, 'redux-color-picker-css', ReduxFramework::$_url . 'assets/css/color-picker/color-picker.css', ReduxFramework::$_dir . 'assets/css/color-picker', array(), time(), false); // wp_enqueue_style( // 'redux-color-picker-css', // self::$_url . 'assets/css/color-picker/color-picker.css', // array( 'wp-color-picker' ), // filemtime( self::$_dir . 'assets/css/color-picker/color-picker.css' ), // 'all' // ); wp_enqueue_style('color-picker-css'); wp_enqueue_script('wp-color-picker'); wp_enqueue_style('wp-color-picker'); } if (function_exists('wp_enqueue_media')) { wp_enqueue_media(); } else { wp_enqueue_script('media-upload'); } add_thickbox(); wp_register_script('qtip-js', self::$_url . 'assets/js/vendor/qtip/jquery.qtip.js', array('jquery'), '2.2.0', true); wp_register_script('serializeForm-js', self::$_url . 'assets/js/vendor/jquery.serializeForm.js', array('jquery'), '1.0.0', true); // Embed the compress version unless in dev mode // dev_mode = true if (isset($this->args['dev_mode']) && $this->args['dev_mode'] == true) { //wp_enqueue_style( 'admin-css' ); wp_register_script('redux-vendor', self::$_url . 'assets/js/vendor.min.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor.min.js'), true); // dev_mode - false } else { //wp_enqueue_style( 'redux-css' ); } $depArray = array('jquery', 'qtip-js', 'serializeForm-js'); if (true == $this->args['dev_mode']) { array_push($depArray, 'redux-vendor'); } wp_register_script('redux-js', self::$_url . 'assets/js/redux' . $min . '.js', $depArray, filemtime(self::$_dir . 'assets/js/redux' . $min . '.js'), true); foreach ($this->sections as $section) { if (isset($section['fields'])) { foreach ($section['fields'] as $field) { // TODO AFTER GROUP WORKS - Revert IF below // if( isset( $field['type'] ) && $field['type'] != 'callback' ) { if (isset($field['type']) && $field['type'] != 'callback') { $field_class = 'ReduxFramework_' . $field['type']; /** * Field class file * filter 'redux/{opt_name}/field/class/{field.type} * * @param string field class file path * @param array $field field config data */ $class_file = apply_filters("redux/{$this->args['opt_name']}/field/class/{$field['type']}", self::$_dir . "inc/fields/{$field['type']}/field_{$field['type']}.php", $field); if ($class_file) { if (!class_exists($field_class)) { if (file_exists($class_file)) { require_once $class_file; } } if (method_exists($field_class, 'enqueue') || method_exists($field_class, 'localize')) { if (!isset($this->options[$field['id']])) { $this->options[$field['id']] = ""; } $theField = new $field_class($field, $this->options[$field['id']], $this); // Move dev_mode check to a new if/then block if (!wp_script_is('redux-field-' . $field['type'] . '-js', 'enqueued') && class_exists($field_class) && method_exists($field_class, 'enqueue')) { // Checking for extension field AND dev_mode = false OR dev_mode = true // Since extension fields use 'extension_dir' exclusively, we can detect them here. // Also checking for dev_mode = true doesn't mess up the JS combinine. //if ( /*$this->args['dev_mode'] === false && */ isset($theField->extension_dir) && (!'' == $theField->extension_dir) /* || ($this->args['dev_mode'] === true) */) { $theField->enqueue(); //print_r($field['type']); //} } if (method_exists($field_class, 'localize')) { $params = $theField->localize($field); if (!isset($this->localize_data[$field['type']])) { $this->localize_data[$field['type']] = array(); } $this->localize_data[$field['type']][$field['id']] = $theField->localize($field); } unset($theField); } } } } } } if ($this->args['sass']['enabled']) { reduxSassCompiler::compile_sass($this); if (!$this->args['sass']['page_output']) { wp_enqueue_style('redux-css', ReduxFramework::$_upload_url . $this->args['opt_name'] . '-redux.css', array(), time(), 'all'); } } $this->localize_data['required'] = $this->required; $this->localize_data['fonts'] = $this->fonts; $this->localize_data['required_child'] = $this->required_child; $this->localize_data['fields'] = $this->fields; if (isset($this->font_groups['google'])) { $this->localize_data['googlefonts'] = $this->font_groups['google']; } if (isset($this->font_groups['std'])) { $this->localize_data['stdfonts'] = $this->font_groups['std']; } if (isset($this->font_groups['customfonts'])) { $this->localize_data['customfonts'] = $this->font_groups['customfonts']; } $this->localize_data['folds'] = $this->folds; // Make sure the children are all hidden properly. foreach ($this->fields as $key => $value) { if (in_array($key, $this->fieldsHidden)) { foreach ($value as $k => $v) { if (!in_array($k, $this->fieldsHidden)) { $this->fieldsHidden[] = $k; $this->folds[$k] = "hide"; } } } } if (isset($this->args['dev_mode']) && $this->args['dev_mode'] == true) { $base = admin_url('admin-ajax.php') . '?action=redux_p&url='; $url = $base . urlencode('http://ads.reduxframework.com/api/index.php?js&g&1&v=2') . '&proxy=' . urlencode($base); $this->localize_data['rAds'] = '<span data-id="1" class="mgv1_1"><script type="text/javascript">(function(){if (mysa_mgv1_1) return; var ma = document.createElement("script"); ma.type = "text/javascript"; ma.async = true; ma.src = "' . $url . '"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ma, s) })();var mysa_mgv1_1=true;</script></span>'; } $this->localize_data['fieldsHidden'] = $this->fieldsHidden; $this->localize_data['options'] = $this->options; $this->localize_data['defaults'] = $this->options_defaults; /** * Save pending string * filter 'redux/{opt_name}/localize/save_pending * * @param string save_pending string */ $save_pending = apply_filters("redux/{$this->args['opt_name']}/localize/save_pending", __('You have changes that are not saved. Would you like to save them now?', 'redux-framework')); /** * Reset all string * filter 'redux/{opt_name}/localize/reset * * @param string reset all string */ $reset_all = apply_filters("redux/{$this->args['opt_name']}/localize/reset", __('Are you sure? Resetting will lose all custom values.', 'redux-framework')); /** * Reset section string * filter 'redux/{opt_name}/localize/reset_section * * @param string reset section string */ $reset_section = apply_filters("redux/{$this->args['opt_name']}/localize/reset_section", __('Are you sure? Resetting will lose all custom values in this section.', 'redux-framework')); /** * Preset confirm string * filter 'redux/{opt_name}/localize/preset * * @param string preset confirm string */ $preset_confirm = apply_filters("redux/{$this->args['opt_name']}/localize/preset", __('Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework')); global $pagenow; $this->localize_data['args'] = array('save_pending' => $save_pending, 'reset_confirm' => $reset_all, 'reset_section_confirm' => $reset_section, 'preset_confirm' => $preset_confirm, 'please_wait' => __('Please Wait', 'redux-framework'), 'opt_name' => $this->args['opt_name'], 'slug' => $this->args['page_slug'], 'hints' => $this->args['hints'], 'disable_save_warn' => $this->args['disable_save_warn'], 'class' => $this->args['class'], 'menu_search' => $pagenow . '?page=' . $this->args['page_slug'] . "&tab="); // Construct the errors array. if (isset($this->transients['last_save_mode']) && !empty($this->transients['notices']['errors'])) { $theTotal = 0; $theErrors = array(); foreach ($this->transients['notices']['errors'] as $error) { $theErrors[$error['section_id']]['errors'][] = $error; if (!isset($theErrors[$error['section_id']]['total'])) { $theErrors[$error['section_id']]['total'] = 0; } $theErrors[$error['section_id']]['total']++; $theTotal++; } $this->localize_data['errors'] = array('total' => $theTotal, 'errors' => $theErrors); unset($this->transients['notices']['errors']); } // Construct the warnings array. if (isset($this->transients['last_save_mode']) && !empty($this->transients['notices']['warnings'])) { $theTotal = 0; $theWarnings = array(); foreach ($this->transients['notices']['warnings'] as $warning) { $theWarnings[$warning['section_id']]['warnings'][] = $warning; if (!isset($theWarnings[$warning['section_id']]['total'])) { $theWarnings[$warning['section_id']]['total'] = 0; } $theWarnings[$warning['section_id']]['total']++; $theTotal++; } unset($this->transients['notices']['warnings']); $this->localize_data['warnings'] = array('total' => $theTotal, 'warnings' => $theWarnings); } if (empty($this->transients['notices'])) { unset($this->transients['notices']); } // Values used by the javascript wp_localize_script('redux-js', 'redux', $this->localize_data); wp_enqueue_script('redux-js'); // Enque the JS now wp_enqueue_script('webfontloader', 'https://ajax.googleapis.com/ajax/libs/webfont/1.5.0/webfont.js', array('jquery'), '1.5.0', true); /** * action 'redux-enqueue-{opt_name}' * * @deprecated * * @param object $this ReduxFramework */ do_action("redux-enqueue-{$this->args['opt_name']}", $this); // REMOVE /** * action 'redux/page/{opt_name}/enqueue' */ do_action("redux/page/{$this->args['opt_name']}/enqueue"); }
/** * Class Constructor. Defines the args for the theme options class * * @since 1.0.0 * * @param array $sections Panel sections. * @param array $args Class constructor arguments. * @param array $extra_tabs Extra panel tabs. // REMOVE * * @return \ReduxFramework */ public function __construct($sections = array(), $args = array(), $extra_tabs = array()) { // Disregard WP AJAX 'heartbeat'call. Why waste resources? if (isset($_POST) && isset($_POST['action']) && $_POST['action'] == 'heartbeat') { // Hook, for purists. if (!has_action('redux/ajax/heartbeat')) { do_action('redux/ajax/heartbeat', $this); } // Buh bye! return; } // Pass parent pointer to function helper. Redux_Functions::$_parent = $this; Redux_CDN::$_parent = $this; // Set values $this->set_default_args(); $this->args = wp_parse_args($args, $this->args); if (empty($this->args['transient_time'])) { $this->args['transient_time'] = 60 * MINUTE_IN_SECONDS; } if (empty($this->args['footer_credit'])) { $this->args['footer_credit'] = '<span id="footer-thankyou">' . sprintf(__('Versão do tema: %1$s', 'redux-framework'), THEME_VERSION) . '</span>'; } if (empty($this->args['menu_title'])) { $this->args['menu_title'] = __('Options', 'redux-framework'); } if (empty($this->args['page_title'])) { $this->args['page_title'] = __('Options', 'redux-framework'); } $this->old_opt_name = $this->args['opt_name']; /** * filter 'redux/args/{opt_name}' * * @param array $args ReduxFramework configuration */ $this->args = apply_filters("redux/args/{$this->args['opt_name']}", $this->args); /** * filter 'redux/options/{opt_name}/args' * * @param array $args ReduxFramework configuration */ $this->args = apply_filters("redux/options/{$this->args['opt_name']}/args", $this->args); if ($this->args['opt_name'] == $this->old_opt_name) { unset($this->old_opt_name); } // Do not save the defaults if we're on a live preview! if ($GLOBALS['pagenow'] == "customize" && isset($_GET['theme']) && !empty($_GET['theme'])) { $this->args['save_defaults'] = false; } if (!empty($this->args['opt_name'])) { /** * SHIM SECTION * Old variables and ways of doing things that need correcting. ;) * */ // Variable name change if (!empty($this->args['page_cap'])) { $this->args['page_permissions'] = $this->args['page_cap']; unset($this->args['page_cap']); } if (!empty($this->args['page_position'])) { $this->args['page_priority'] = $this->args['page_position']; unset($this->args['page_position']); } if (!empty($this->args['page_type'])) { $this->args['menu_type'] = $this->args['page_type']; unset($this->args['page_type']); } // Get rid of extra_tabs! Not needed. if (is_array($extra_tabs) && !empty($extra_tabs)) { foreach ($extra_tabs as $tab) { array_push($this->sections, $tab); } } // Move to the first loop area! /** * filter 'redux-sections' * * @deprecated * * @param array $sections field option sections */ $this->sections = apply_filters('redux-sections', $sections); // REMOVE LATER /** * filter 'redux-sections-{opt_name}' * * @deprecated * * @param array $sections field option sections */ $this->sections = apply_filters("redux-sections-{$this->args['opt_name']}", $this->sections); // REMOVE LATER /** * filter 'redux/options/{opt_name}/sections' * * @param array $sections field option sections */ $this->sections = apply_filters("redux/options/{$this->args['opt_name']}/sections", $this->sections); /** * Construct hook * action 'redux/construct' * * @param object $this ReduxFramework */ do_action('redux/construct', $this); // Set the default values $this->_default_cleanup(); // Internataionalization $this->_internationalization(); $this->filesystem = new Redux_Filesystem($this); //set redux upload folder $this->set_redux_content(); // Register extra extensions $this->_register_extensions(); // Grab database values $this->get_options(); // Tracking if (true != Redux_Helpers::isTheme(__FILE__) || true == Redux_Helpers::isTheme(__FILE__) && !$this->args['disable_tracking']) { $this->_tracking(); } // Options page add_action('admin_menu', array($this, '_options_page')); // Add a network menu if ($this->args['database'] == "network" && $this->args['network_admin']) { add_action('network_admin_menu', array($this, '_options_page')); } // Admin Bar menu add_action('admin_bar_menu', array($this, '_admin_bar_menu'), $this->args['admin_bar_priority']); // Register setting add_action('admin_init', array($this, '_register_settings')); // Display admin notices in dev_mode //if ( true == $this->args['dev_mode'] ) { //if ( true == $this->args['update_notice'] ) { // add_action( 'admin_init', array( $this, '_update_check' ) ); //} //} // Display admin notices //add_action( 'admin_notices', array( $this, '_admin_notices' ), 99 ); // Check for dismissed admin notices. add_action('admin_init', array($this, '_dismiss_admin_notice'), 9); // Enqueue the admin page CSS and JS if (isset($_GET['page']) && $_GET['page'] == $this->args['page_slug']) { add_action('admin_enqueue_scripts', array($this, '_enqueue'), 1); } // Output dynamic CSS // Frontend: Maybe enqueue dynamic CSS and Google fonts if (empty($this->args['output_location']) || in_array('frontend', $this->args['output_location'])) { add_action('wp_head', array(&$this, '_output_css'), 150); add_action('wp_enqueue_scripts', array(&$this, '_enqueue_output'), 150); } // Login page: Maybe enqueue dynamic CSS and Google fonts if (in_array('login', $this->args['output_location'])) { add_action('login_head', array(&$this, '_output_css'), 150); add_action('login_enqueue_scripts', array(&$this, '_enqueue_output'), 150); } // Admin area: Maybe enqueue dynamic CSS and Google fonts if (in_array('admin', $this->args['output_location'])) { add_action('admin_head', array(&$this, '_output_css'), 150); add_action('admin_enqueue_scripts', array(&$this, '_enqueue_output'), 150); } add_action('wp_print_scripts', array($this, 'vc_fixes'), 100); add_action('admin_enqueue_scripts', array($this, 'vc_fixes'), 100); if ($this->args['database'] == "network" && $this->args['network_admin']) { add_action('network_admin_edit_redux_' . $this->args['opt_name'], array($this, 'save_network_page'), 10, 0); add_action('admin_bar_menu', array($this, 'network_admin_bar'), 999); } // Ajax saving!!! add_action("wp_ajax_" . $this->args['opt_name'] . '_ajax_save', array($this, "ajax_save")); if ($this->args['dev_mode'] == true || Redux_Helpers::isLocalHost() == true) { //include_once 'core/dashboard.php'; if (!isset($GLOBALS['redux_notice_check'])) { include_once 'core/newsflash.php'; $params = array('dir_name' => 'notice', 'server_file' => 'http://www.reduxframework.com/' . 'wp-content/uploads/redux/redux_notice.json', 'interval' => 3, 'cookie_id' => 'redux_blast'); new reduxNewsflash($this, $params); $GLOBALS['redux_notice_check'] = 1; } } } /** * Loaded hook * action 'redux/loaded' * * @param object $this ReduxFramework */ do_action('redux/loaded', $this); }
/** * Enqueue CSS/JS for options page * * @since 1.0.0 * @access public * @global $wp_styles * @return void */ public function _enqueue() { global $wp_styles; Redux_Functions::$_parent = $this; $min = Redux_Functions::isMin(); // Select2 business. Fields: Background, Border, Dimensions, Select, Slider, Typography if (Redux_Helpers::isFieldInUseByType($this->fields, array('background', 'border', 'dimensions', 'select', 'slider', 'typography'))) { // select2 CSS wp_register_style('select2-css', self::$_url . 'assets/js/vendor/select2/select2.css', array(), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.css'), 'all'); wp_enqueue_style('select2-css'); // JS wp_register_script('select2-sortable-js', self::$_url . 'assets/js/vendor/select2.sortable.min.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor/select2.sortable.min.js'), true); wp_register_script('select2-js', self::$_url . 'assets/js/vendor/select2/select2.min.js', array('jquery', 'select2-sortable-js'), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.min.js'), true); wp_enqueue_script('select2-js'); } wp_register_style('redux-css', self::$_url . 'assets/css/redux.css', array('farbtastic'), filemtime(self::$_dir . 'assets/css/redux.css'), 'all'); wp_register_style('admin-css', self::$_url . 'assets/css/admin.css', array('farbtastic'), filemtime(self::$_dir . 'assets/css/admin.css'), 'all'); wp_register_style('redux-elusive-icon', self::$_url . 'assets/css/vendor/elusive-icons/elusive-webfont.css', array(), filemtime(self::$_dir . 'assets/css/vendor/elusive-icons/elusive-webfont.css'), 'all'); wp_register_style('redux-elusive-icon-ie7', self::$_url . 'assets/css/vendor/elusive-icons/elusive-webfont-ie7.css', array(), filemtime(self::$_dir . 'assets/css/vendor/elusive-icons/elusive-webfont-ie7.css'), 'all'); wp_register_style('qtip-css', self::$_url . 'assets/css/vendor/qtip/jquery.qtip.css', array(), filemtime(self::$_dir . 'assets/css/vendor/qtip/jquery.qtip.css'), 'all'); $wp_styles->add_data('redux-elusive-icon-ie7', 'conditional', 'lte IE 7'); /** * jQuery UI stylesheet src * filter 'redux/page/{opt_name}/enqueue/jquery-ui-css' * @param string bundled stylesheet src */ wp_register_style('jquery-ui-css', apply_filters("redux/page/{$this->args['opt_name']}/enqueue/jquery-ui-css", self::$_url . 'assets/css/vendor/jquery-ui-bootstrap/jquery-ui-1.10.0.custom.css'), '', filemtime(self::$_dir . 'assets/css/vendor/jquery-ui-bootstrap/jquery-ui-1.10.0.custom.css'), 'all'); wp_enqueue_style('jquery-ui-css'); wp_enqueue_style('redux-lte-ie8'); wp_enqueue_style('qtip-css'); wp_enqueue_style('redux-elusive-icon'); wp_enqueue_style('redux-elusive-icon-ie7'); if (is_rtl()) { wp_register_style('redux-rtl-css', self::$_url . 'assets/css/rtl.css', '', filemtime(self::$_dir . 'assets/css/rtl.css'), 'all'); wp_enqueue_style('redux-rtl-css'); } wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-dialog'); // Load jQuery sortable for slides, sorter, sortable and group if (Redux_Helpers::isFieldInUseByType($this->fields, array('slides', 'sorter', 'sortable', 'group'))) { wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_style('jquery-ui-sortable'); } // Load jQuery UI Datepicker for date if (Redux_Helpers::isFieldInUseByType($this->fields, array('date'))) { wp_enqueue_script('jquery-ui-datepicker'); } // Load jQuery UI Accordion for slides and group if (Redux_Helpers::isFieldInUseByType($this->fields, array('slides', 'group'))) { wp_enqueue_script('jquery-ui-accordion'); } // Load wp-color-picker for color, color_gradient, link_color, border, and typography if (Redux_Helpers::isFieldInUseByType($this->fields, array('color', 'color_gradient', 'link_color', 'border', 'typography'))) { wp_enqueue_script('wp-color-picker'); wp_enqueue_style('wp-color-picker'); } if (function_exists('wp_enqueue_media')) { wp_enqueue_media(); } else { wp_enqueue_script('media-upload'); } add_thickbox(); wp_register_script('qtip-js', self::$_url . 'assets/js/vendor/qtip/jquery.qtip.js', array('jquery'), '2.2.0', true); wp_register_script('serializeForm-js', self::$_url . 'assets/js/vendor/jquery.serializeForm.js', array('jquery'), '1.0.0', true); // Embed the compress version unless in dev mode // dev_mode = true if (isset($this->args['dev_mode']) && $this->args['dev_mode'] === true) { wp_enqueue_style('admin-css'); wp_register_script('redux-vendor', self::$_url . 'assets/js/vendor.min.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor.min.js'), true); // dev_mode - false } else { wp_enqueue_style('redux-css'); } $depArray = array('jquery', 'qtip-js', 'serializeForm-js'); if (true === $this->args['dev_mode']) { array_push($depArray, 'redux-vendor'); } wp_register_script('redux-js', self::$_url . 'assets/js/redux' . $min . '.js', $depArray, filemtime(self::$_dir . 'assets/js/redux' . $min . '.js'), true); foreach ($this->sections as $section) { if (isset($section['fields'])) { foreach ($section['fields'] as $field) { // TODO AFTER GROUP WORKS - Revert IF below // if( isset( $field['type'] ) && $field['type'] != 'callback' ) { if (isset($field['type']) && $field['type'] != 'callback' && $field['type'] != 'group') { $field_class = 'ReduxFramework_' . $field['type']; /** * Field class file * * filter 'redux/{opt_name}/field/class/{field.type} * @param string field class file path * @param array $field field config data */ $class_file = apply_filters("redux/{$this->args['opt_name']}/field/class/{$field['type']}", self::$_dir . "inc/fields/{$field['type']}/field_{$field['type']}.php", $field); if ($class_file) { if (!class_exists($field_class)) { if (file_exists($class_file)) { require_once $class_file; } } if (method_exists($field_class, 'enqueue') || method_exists($field_class, 'localize')) { if (!isset($this->options[$field['id']])) { $this->options[$field['id']] = ""; } $theField = new $field_class($field, $this->options[$field['id']], $this); // Move dev_mode check to a new if/then block if (!wp_script_is('redux-field-' . $field['type'] . '-js', 'enqueued') && class_exists($field_class) && method_exists($field_class, 'enqueue')) { // Checking for extension field AND dev_mode = false OR dev_mode = true // Since extension fields use 'extension_dir' exclusively, we can detect them here. // Also checking for dev_mode = true doesn't mess up the JS combinine. //if ( /*$this->args['dev_mode'] === false && */ isset($theField->extension_dir) && (!'' == $theField->extension_dir) /* || ($this->args['dev_mode'] === true) */) { $theField->enqueue(); //} } if (method_exists($field_class, 'localize')) { $params = $theField->localize($field); if (!isset($this->localize_data[$field['type']])) { $this->localize_data[$field['type']] = array(); } $this->localize_data[$field['type']][$field['id']] = $theField->localize($field); } unset($theField); } } } } } } $this->localize_data['required'] = $this->required; $this->localize_data['fonts'] = $this->fonts; $this->localize_data['required_child'] = $this->required_child; $this->localize_data['fields'] = $this->fields; $this->localize_data['fonts'] = $this->fonts; $this->localize_data['folds'] = $this->folds; // Make sure the children are all hidden properly. foreach ($this->fields as $key => $value) { if (in_array($key, $this->fieldsHidden)) { foreach ($value as $k => $v) { if (!in_array($k, $this->fieldsHidden)) { $this->fieldsHidden[] = $k; $this->folds[$k] = "hide"; } } } } $this->localize_data['fieldsHidden'] = $this->fieldsHidden; $this->localize_data['options'] = $this->options; $this->localize_data['defaults'] = $this->options_defaults; $this->localize_data['args'] = array('save_pending' => __('You have changes that are not saved. Would you like to save them now?', 'redux-framework'), 'reset_confirm' => __('Are you sure? Resetting will lose all custom values.', 'redux-framework'), 'reset_section_confirm' => __('Are you sure? Resetting will lose all custom values in this section.', 'redux-framework'), 'preset_confirm' => __('Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework'), 'please_wait' => __('Please Wait', 'redux-framework'), 'opt_name' => $this->args['opt_name'], 'slug' => $this->args['page_slug'], 'hints' => $this->args['hints'], 'disable_save_warn' => $this->args['disable_save_warn'], 'class' => $this->args['class']); // Construct the errors array. if (isset($this->transients['last_save_mode']) && !empty($this->transients['notices']['errors'])) { $theTotal = 0; $theErrors = array(); foreach ($this->transients['notices']['errors'] as $error) { $theErrors[$error['section_id']]['errors'][] = $error; if (!isset($theErrors[$error['section_id']]['total'])) { $theErrors[$error['section_id']]['total'] = 0; } $theErrors[$error['section_id']]['total']++; $theTotal++; } $this->localize_data['errors'] = array('total' => $theTotal, 'errors' => $theErrors); unset($this->transients['notices']['errors']); } // Construct the warnings array. if (isset($this->transients['last_save_mode']) && !empty($this->transients['notices']['warnings'])) { $theTotal = 0; $theWarnings = array(); foreach ($this->transients['notices']['warnings'] as $warning) { $theWarnings[$warning['section_id']]['warnings'][] = $warning; if (!isset($theWarnings[$warning['section_id']]['total'])) { $theWarnings[$warning['section_id']]['total'] = 0; } $theWarnings[$warning['section_id']]['total']++; $theTotal++; } unset($this->transients['notices']['warnings']); $this->localize_data['warnings'] = array('total' => $theTotal, 'warnings' => $theWarnings); } if (empty($this->transients['notices'])) { unset($this->transients['notices']); } // Values used by the javascript wp_localize_script('redux-js', 'redux', $this->localize_data); wp_enqueue_script('redux-js'); // Enque the JS now wp_enqueue_script('webfontloader', 'https://ajax.googleapis.com/ajax/libs/webfont/1.5.0/webfont.js', array('jquery'), '1.5.0', true); /** * action 'redux-enqueue-{opt_name}' * @deprecated * @param object $this ReduxFramework */ do_action("redux-enqueue-{$this->args['opt_name']}", $this); // REMOVE /** * action 'redux/page/{opt_name}/enqueue' */ do_action("redux/page/{$this->args['opt_name']}/enqueue"); }
/** * Class Constructor. Defines the args for the theme options class * @since 1.0.0 * @param array $sections Panel sections. * @param array $args Class constructor arguments. * @param array $extra_tabs Extra panel tabs. // REMOVE * @return \ReduxFramework */ public function __construct($sections = array(), $args = array(), $extra_tabs = array()) { global $wp_version; // Disregard WP AJAX 'heartbeat'call. Why waste resources? if (isset($_POST) && isset($_POST['action']) && $_POST['action'] == 'heartbeat') { // Hook, for purists. if (!has_action('redux/ajax/heartbeat')) { do_action('redux/ajax/heartbeat', $this); } // Buh bye! return; } // Pass parent pointer to function helper. Redux_Functions::$_parent = $this; // Set values $this->args = wp_parse_args($args, $this->args); if (empty($this->args['transient_time'])) { $this->args['transient_time'] = 60 * MINUTE_IN_SECONDS; } if (empty($this->args['footer_credit'])) { $this->args['footer_credit'] = '<span id="footer-thankyou">' . sprintf(__('Options panel created using %1$s', 'redux-framework'), '<a href="' . esc_url($this->framework_url) . '" target="_blank">' . __('Redux Framework', 'redux-framework') . '</a> v' . self::$_version) . '</span>'; } if (empty($this->args['menu_title'])) { $this->args['menu_title'] = __('Options', 'redux-framework'); } if (empty($this->args['page_title'])) { $this->args['page_title'] = __('Options', 'redux-framework'); } /** * filter 'redux/args/{opt_name}' * @param array $args ReduxFramework configuration */ $this->args = apply_filters("redux/args/{$this->args['opt_name']}", $this->args); /** * filter 'redux/options/{opt_name}/args' * @param array $args ReduxFramework configuration */ $this->args = apply_filters("redux/options/{$this->args['opt_name']}/args", $this->args); if (!empty($this->args['opt_name'])) { /** SHIM SECTION Old variables and ways of doing things that need correcting. ;) **/ // Variable name change if (!empty($this->args['page_cap'])) { $this->args['page_permissions'] = $this->args['page_cap']; unset($this->args['page_cap']); } if (!empty($this->args['page_position'])) { $this->args['page_priority'] = $this->args['page_position']; unset($this->args['page_position']); } if (!empty($this->args['page_type'])) { $this->args['menu_type'] = $this->args['page_type']; unset($this->args['page_type']); } // Get rid of extra_tabs! Not needed. if (is_array($extra_tabs) && !empty($extra_tabs)) { foreach ($extra_tabs as $tab) { array_push($this->sections, $tab); } } // Move to the first loop area! /** * filter 'redux-sections' * @deprecated * @param array $sections field option sections */ $this->sections = apply_filters('redux-sections', $sections); // REMOVE LATER /** * filter 'redux-sections-{opt_name}' * @deprecated * @param array $sections field option sections */ $this->sections = apply_filters("redux-sections-{$this->args['opt_name']}", $this->sections); // REMOVE LATER /** * filter 'redux/options/{opt_name}/sections' * @param array $sections field option sections */ $this->sections = apply_filters("redux/options/{$this->args['opt_name']}/sections", $this->sections); /** * Construct hook * action 'redux/construct' * @param object $this ReduxFramework */ do_action('redux/construct', $this); // Set the default values $this->_default_cleanup(); // Internataionalization $this->_internationalization(); // Register extra extensions $this->_register_extensions(); // Grab database values $this->get_options(); // Tracking $this->_tracking(); // Set option with defaults //add_action( 'init', array( &$this, '_set_default_options' ), 101 ); // Options page add_action('admin_menu', array($this, '_options_page')); // Admin Bar menu add_action('admin_bar_menu', array($this, '_admin_bar_menu'), 999); // Register setting add_action('admin_init', array($this, '_register_settings')); // Display admin notices in dev_mode if (true == $this->args['dev_mode']) { include_once self::$_dir . 'inc/debug.php'; $this->debug = new ReduxDebugObject($this); if (true == $this->args['update_notice']) { add_action('admin_init', array($this, '_update_check')); } } // Display admin notices add_action('admin_notices', array($this, '_admin_notices')); // Check for dismissed admin notices. add_action('admin_init', array($this, '_dismiss_admin_notice'), 9); // Enqueue the admin page CSS and JS if (isset($_GET['page']) && $_GET['page'] == $this->args['page_slug']) { add_action('admin_enqueue_scripts', array($this, '_enqueue')); } // Any dynamic CSS output, let's run add_action('wp_head', array(&$this, '_enqueue_output'), 150); require_once self::$_dir . 'inc/fields/import_export/import_export.php'; $this->import_export = new Redux_import_export($this); // mod_rewrite check //Redux_Functions::modRewriteCheck(); } /** * Loaded hook * * action 'redux/loaded' * @param object $this ReduxFramework */ do_action('redux/loaded', $this); }