set_deprecate_version(); // Get all themes $this->themes = wp_get_themes(); // Get all nav menus $this->nav_menus = wp_get_nav_menus(); // Adds the license field to settings add_filter('apppresser_theme_settings_file', function() { return get_theme_root() . '/ap3-ion-theme/appp-settings.php'; }); // include theme settings file if it exists $this->get_theme_settings_file(); add_action( 'admin_menu', array( $this, 'plugin_menu' ), 9 ); add_filter( 'sanitize_option_'. AppPresser::SETTINGS_NAME, array( $this, 'maybe_reset_license_statuses' ), 99 ); add_action( 'update_option_' . AppPresser::SETTINGS_NAME, array( $this, 'save_theme_mods'), 99, 2 ); add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'admin_notices') ); add_action( 'apppresser_add_settings', array( $this, 'add_settings' ), 6 ); // Higher priority add_filter( 'apppresser_field_markup_text', array( $this, 'ajax_container' ), 10, 2 ); add_action( 'wp_ajax_appp_search_post_handler', array( $this, 'ajax_post_results' ) ); add_action( 'admin_head', array( $this, 'icon_styles' ) ); add_action( 'wp_ajax_appp_hide_quickstart', array( $this, 'ajax_hide_quickstart' ) ); add_action( 'after_appp_add_settings', array( $this, 'migrate_theme_mods' ) ); } /** * phonegap_versions function. * * @access public * @return array */ public function phonegap_versions() { return $pg_versions = array( '3.5.0' => '3.5.0', '3.6.3' => '3.6.3', '3.7.0' => '3.7.0' ); } /** * get_theme_settings_file function. * * @access public * @return void */ public function get_theme_settings_file() { // Get saved apppresser theme $appp_theme = self::settings( 'appp_theme' ); // Check for the 'Use different theme for app?' option if ( $appp_theme ) { // If admin only theme object exists if ( isset( $this->themes[ $appp_theme ] ) && is_callable( array( $this->themes[ $appp_theme ], 'get_template_directory' ) ) ) { // Let themes override the location/name of the file $file_override = apply_filters( 'apppresser_theme_settings_file', '' ); if ( $file_override && file_exists( $file_override ) ) { require_once( $file_override ); } // Check child theme directory first $dir = $this->themes[ $appp_theme ]->get_stylesheet_directory(); // If there is a 'appp-settings.php' file, if ( file_exists( $dir .'/appp-settings.php' ) ) { // include it return require_once( $dir .'/appp-settings.php' ); } // Ok, check parent theme directory $dir = $this->themes[ $appp_theme ]->get_template_directory(); // If there is a 'appp-settings.php' file, if ( file_exists( $dir .'/appp-settings.php' ) ) { // include it return require_once( $dir .'/appp-settings.php' ); } } } // Otherwise if there is a 'appp-settings.php' file in the currently active theme, elseif ( file_exists( get_stylesheet_directory_uri() .'/appp-settings.php' ) ) { // include it return require_once( get_stylesheet_directory_uri() .'/appp-settings.php' ); } /** * @since 3.0.2 * If not upgrading from AP2, new installs may not have * appp_theme setting so include AP3 theme settings here */ $file_override = apply_filters( 'apppresser_theme_settings_file', '' ); if ( $file_override && file_exists( $file_override ) ) { require_once( $file_override ); } } /** * Create AppPresser Settings menus * @since 1.0.0 */ function plugin_menu() { $page_title = __( 'AppPresser', 'apppresser' ); // Create main menu and settings page self::$menu_slug = add_menu_page( $page_title, $page_title, 'manage_options', self::$page_slug, array( $this, 'settings_page' ) ); // Settings page submenu item self::$setting_menu_slug = add_submenu_page( self::$page_slug, __( 'Settings', 'apppresser' ), __( 'Settings', 'apppresser' ), 'manage_options', self::$page_slug, array( $this, 'settings_page' ) ); // Help page submenu item self::$help_menu_slug = add_submenu_page( self::$page_slug, __( 'Help / Support', 'apppresser' ), __( 'Help / Support', 'apppresser' ), 'manage_options', self::$help_slug, array( $this, 'help_support_page' ) ); add_action( 'admin_head-' . self::$menu_slug, array( $this, 'admin_head' ) ); // enqueue foreach ( array( self::$menu_slug, self::$help_menu_slug, self::$setting_menu_slug ) as $slug ) { add_action( 'admin_print_scripts-' . $slug, array( $this, 'admin_scripts' ) ); } add_action('admin_head', array( $this, 'apppush_admin_css' ) ); // Add notification bubble if any notifications if ( $notifications = $this->notification_badge() ) { global $menu; // Add the notification bubble to our top level menu foreach ( $menu as $menu_key => $menu_item ) { if ( isset( $menu_item[2] ) && self::$page_slug == $menu_item[2] ) { $menu[ $menu_key ][0] = $menu_item[0] . $notifications; } } } } /** * Even though we are no longer using the customizer for appp_settings, we * still need the menu choices saved into the theme_mods_{theme_slug} option * * hooks into the update_option_{appp_settings} * * @since 2.7.0 */ public function save_theme_mods($old_appp_settings, $appp_settings) { if( isset( $appp_settings['appp_theme'] ) ) { $stylesheet = $appp_settings['appp_theme']; // get our existing theme_mods $theme_mod = get_option( 'theme_mods_' . $stylesheet ); // Menus if( isset( $appp_settings['menu'] ) || isset( $appp_settings['secondary_menu'] ) ) { // nav_menu_locations ? if( $theme_mod === false || ! isset( $theme_mod['nav_menu_locations'] ) ) { $theme_mod['nav_menu_locations'] = array(); } if( isset( $appp_settings['menu'] ) ) { $theme_mod['nav_menu_locations']['primary-menu'] = (int)$appp_settings['menu']; // ion $theme_mod['nav_menu_locations']['primary'] = (int)$appp_settings['menu']; // apptheme } if( isset( $appp_settings['secondary_menu'] ) ) { $theme_mod['nav_menu_locations']['footer-menu'] = (int)$appp_settings['secondary_menu']; } if( isset( $appp_settings['top_menu'] ) ) { $theme_mod['nav_menu_locations']['top'] = (int)$appp_settings['top_menu']; // apptheme } if( isset( $appp_settings['top_2_menu'] ) ) { $theme_mod['nav_menu_locations']['top2'] = (int)$appp_settings['top_2_menu']; // apptheme } } $settings_keys = array( 'list_control' => '', 'ab_color_mod' => '', 'ab_image_mod' => '', 'ab_text_mod' => '', 'ap_color_mod' => '', 'slider_control' => 'int', 'slider_category_control' => '', ); foreach ($settings_keys as $key => $type) { if( isset( $appp_settings[$key] ) ) { if($type == 'int') { $theme_mod[$key] = (int)$appp_settings[$key]; } else { $theme_mod[$key] = $appp_settings[$key]; } } } if( isset( $appp_settings['theme_mods_'.$stylesheet]) ) { foreach ( $appp_settings['theme_mods_'.$stylesheet] as $color_key => $color_value ) { $theme_mod[$color_key] = $color_value; } } update_option( 'theme_mods_' . $stylesheet, $theme_mod ); } } /** * This runs pretty late because we need to wait until the color settings * are loaded by the theme's customer class * @since 2.7.0 */ public function migrate_theme_mods() { require_once( self::$inc_path . 'AppPresser_Settings_Migration.php' ); $migrate = new AppPresser_Settings_Migration(); $migrate->migrate_check(); } /** * Admin scripts and styles * @since 1.0.0 */ function admin_scripts() { // admin scripts and styles wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'app-color-picker', plugins_url('js/app-color-picker.js', dirname( __FILE__ ) ), array( 'wp-color-picker' ), false, true ); wp_enqueue_script( 'appp-admin', self::$js_url . 'appp-admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-tooltip', 'wp-color-picker' ), self::VERSION ); wp_enqueue_script( 'appp-admin', self::$js_url . 'appp-admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-tooltip' ), self::VERSION ); wp_enqueue_style( 'jquery-ui-smoothness', self::$css_url . 'smoothness/smoothness.custom.min.css' ); wp_enqueue_style( 'appp-admin-styles', self::$css_url . 'appp-admin-styles.css', null, self::VERSION ); wp_enqueue_media(); } function apppush_admin_css() { global $post_type; if (( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'apppush') || ($post_type == 'apppush')) { echo ""; } } /** * Easy hook for adding to the admin_head on the AppPresser settings page * @since 1.0.0 */ function admin_head() { $appp_settings = self::run(); do_action( 'appp_admin_settings_head', $appp_settings ); } /** * Include css for modifying menu icon * @since 1.0.0 */ function icon_styles() { require_once( self::$dir_path . 'css/icon-styles.php' ); } /** * Register AppPresser Settings with Settings API. * @since 1.0.0 */ function register_settings() { register_setting( 'appp_settings_group', self::SETTINGS_NAME, array( $this, 'settings_validate' ) ); } /** * AppPresser Settings validation * * @since 1.0.0 * @param array $settings The input array we want to validate * @return array Our sanitized inputs */ function settings_validate( $settings ) { $appp_settings = self::run(); // sanitize the settings data submitted foreach ( $settings as $key => $value ) { switch ( $key ) { case 'menu': $cleaninput[ $key ] = absint( $value ); break; case 'mobile_browser_theme_switch': // Clear cookie self::clear_cookie(); $cleaninput[ $key ] = isset( $settings[ $key ] ) && $settings[ $key ] == 'on' ? 'on' : ''; break; case 'admin_theme_switch': $cleaninput[ $key ] = isset( $settings[ $key ] ) && $settings[ $key ] == 'on' ? 'on' : ''; break; case 'theme_mods_' . appp_get_setting('appp_theme'): if( is_array( $value ) ) { $cleaninput[ $key ] = $value; } break; default: // Allow sanitization override $filtered_value = apply_filters( "apppresser_sanitize_setting_$key", null, $value, $settings, $appp_settings ); // If no override, sanitize the value ourselves if( null === $filtered_value && is_string($value)) { $filtered_value = sanitize_text_field( $value ); } else { $filtered_value = $value; } // And fallback sanitization hook (mostly for backwards compatibility) $cleaninput[ $key ] = apply_filters( 'apppresser_sanitize_setting', $filtered_value, $key, $value, $settings, $appp_settings ); break; } // Check for registered license option keys if ( array_key_exists( $key, self::license_keys() ) ) { // Get old value for comparison $old = appp_get_setting( $key ); // we'll do a license check if the old value was either: // empty, different, or the license status was not valid if ( ! $old || $old != $value || ( isset( $settings[$key.'_status'] ) && $settings[$key.'_status'] !== 'valid' ) ) { // if updated, trigger a status check $this->reset_status[] = $key; } } } // Don't delete license keys and other options if a particular plugin is deactivated at the time of saving. // Get existing options $existing = is_array( appp_get_setting() ) ? appp_get_setting() : array(); // Check for keys differing keys from existing option $diff = array_diff_key( $existing, $cleaninput ); // Loop through any differeing keys foreach ( (array) $diff as $field_id => $value ) { // If the field is still registered, ignore it if ( !! self::get_all_fields( $field_id ) ) continue; // If we get here, the field is no longer registered and so the option should be preserved. $cleaninput[ $field_id ] = $diff[ $field_id ]; } return $cleaninput; } /** * Checks for license keys and saves a _status option * @since 1.0.0 * @param array $data Options array * @return array Modified array */ public function maybe_reset_license_statuses( $data ) { // If reset_status is flagged, if ( isset( $this->reset_status ) && is_array( $this->reset_status ) ) { // loop through them foreach ( $this->reset_status as $key ) { // And re-verify the extention's license status $keys = self::license_keys(); $plugin = isset( $keys[ $key ] ) ? $keys[ $key ] : false; $data[ $key .'_status' ] = appp_get_license_status( $data[ $key ], $plugin ); } } return $data; } /** * AppPresser main settings page output * @since 1.0.0 */ public function settings_page() { $appp_settings = self::run(); // Add settings tabs/inputs via this hook. The AppPresser_Admin_Settings instance is passed in. do_action( 'apppresser_add_settings', $appp_settings ); $class = self::$page_slug; $class .= self::is_mp6() ? ' mp6' : ''; ?>
'. __( 'Deprecate AppPresser 2', 'apppresser' ) .'
'; } else { return ''. __( 'Enable AppPresser 2', 'apppresser' ) .'
'; } } /** * Add ajax spinner/results container to homepage selector field * @since 1.0.0 * @param string $html Input html * @param string $key Option field key * @return string Modified input html */ public function ajax_container( $html, $key ) { if ( $key === 'appp_home_page' ) { $html .= ''. __( 'Select a page:', 'apppresser' ) .'
'; } return $html; } /** * Adds a setting section to AppPresser's settings * @since 1.0.0 * @param string $key Option key * @param string $label Option label * @param array $args Array of possible options for select * @return mixed $_field Setting. */ public static function add_setting( $key, $label, $args = array() ) { if( isset( $args['deprecated'] ) && $args['deprecated'] <= self::$deprecate_ver ) return; $appp_settings = self::run(); $value = self::settings( $key ); $keys = array_keys( self::$admin_tabs ); $defaults = array( 'type' => 'text', 'helptext' => '', 'description' => '', 'options' => array(), 'tab' => isset( $args['echo'] ) && $args['echo'] ? 'echoed' : array_shift( $keys ), 'echo' => false, 'subtab' => '', ); $args = wp_parse_args( $args, $defaults ); // Clean values $key = esc_attr( $key ); $label = sanitize_text_field( $label ); $type = esc_attr( $args['type'] ); $options = is_array( $args['options'] ) ? $args['options'] : array(); $help = ! empty( $args['helptext'] ) ? '?' : ''; $field = ''; $_field = ''. trim( $args['description'] ) .'
' : ''; $_field .= '| ' : ''; // help align the description $field .= ''."\n"; $field .= ( $args['description'] ) ? ' | ' : ''; $field .= ( $args['description'] ) ? ' '. $args['description'] .'' : ''; $field .= ( $args['description'] ) ? ' |
%2$s
', $class, $notice ); break; case 'h3': break; case 'title': $field .= '' . $args['value'] . '
'; break; case 'color': $default = ( isset( $args['default'] ) && !empty( $args['default']) ) ? str_replace('##', '#', '#'.$args['default']) : ''; $value = appp_get_theme_mod( $key, $default ); // i.e. #000a7c $appp_theme = appp_get_setting( 'appp_theme' ); // i.e. 'ion' $field .= sprintf('', $value, $appp_theme, $key, $default ); break; case 'file': $field .= sprintf( 'Choose File'."\n", $key, $key, $value ); if ( $args['description'] ) $field .= ' '. $args['description'] .''; break; default: // Filter allows devs to modify default field type or override it $field .= sprintf( ''."\n", $key, $key, $value ); break; } endif; // End check for custom type if ( trim( $args['description'] ) && ! in_array( $type, array( 'h3', 'checkbox' ) ) ) { $field .= ''. trim( $args['description'] ) .'
'; } // Filter allows devs to add their own field types $field = apply_filters( "apppresser_field_markup_$type", $field, $key, $value, $args, $appp_settings ); if ( $type !== 'h3' ) $field .= ': AppPresser | AppPresser
AppPresser', 'Scott Bolinger', 'Brad Williams', 'Brian Messenlehner', 'Lisa Sabin-Wilson' ); ?>.
Justin "JT$" Sternberg', 'Patrick Garman', 'Ryan Fugate', 'Michael "Venkman" Beckwith' ); ?>.
docs.', 'apppresser' ), 'http://v2docs.apppresser.com/article/243-older-versions-of-apptheme-fail-to-update' ); ?>
myapp_disable_remote_updates filter was found and your site will no longer pull design updates from myapppresser.com.', 'apppresser' ) ?>