/** * Let's start Pressin' Apps! * @since 1.0.0 */ function __construct() { $pg_version = appp_get_setting('appp_pg_version') ? appp_get_setting('appp_pg_version') : '3.5.0'; // Define plugin constants self::$dir_path = trailingslashit(plugin_dir_path(__FILE__)); self::$dir_url = trailingslashit(plugins_url(dirname(plugin_basename(__FILE__)))); self::$inc_path = self::$dir_path . 'inc/'; self::$inc_url = self::$dir_url . 'inc/'; self::$css_url = self::$dir_url . 'css/'; self::$img_url = self::$dir_url . 'images/'; self::$js_url = self::$dir_url . 'js/'; self::$pg_url = self::$dir_url . 'pg/' . $pg_version . '/'; self::$l10n = array('ajaxurl' => admin_url('admin-ajax.php'), 'debug' => defined('WP_DEBUG') && WP_DEBUG || defined('SCRIPT_DEBUG') && SCRIPT_DEBUG, 'home_url' => home_url(), 'mobile_browser_theme_switch' => appp_get_setting('mobile_browser_theme_switch'), 'admin_theme_switch' => appp_get_setting('admin_theme_switch'), 'is_appp_true' => self::is_app()); // Load translations load_plugin_textdomain('apppresser', false, dirname(plugin_basename(__FILE__)) . '/languages'); // Setup our activation and deactivation hooks register_activation_hook(__FILE__, array($this, 'activate')); register_deactivation_hook(__FILE__, array($this, 'deactivate')); // Hook in all our important pieces add_action('plugins_loaded', array($this, 'includes')); add_action('wp_enqueue_scripts', array($this, 'frontend_scripts'), 8); add_action('wp_head', array($this, 'do_appp_script'), 1); // remove wp version param from cordova enqueued scripts (so script loading doesn't break) // This will mean that it's harder to break caching on the cordova script add_filter('script_loader_src', array($this, 'remove_query_arg'), 9999); require_once self::$inc_path . 'AppPresser_Admin_Settings.php'; require_once self::$inc_path . 'plugin-updater.php'; require_once self::$inc_path . 'AppPresser_Theme_Customizer.php'; require_once self::$inc_path . 'AppPresser_Ajax_Extras.php'; $this->theme_customizer = new AppPresser_Theme_Customizer(); }
/** * Add a EDD_SL_Plugin_Updater instance * @since 1.0.0 * @param string $plugin_file Path to the plugin file. * @param string $option_key `appp_get_setting` setting key * @param array $api_data Optional data to send with API calls. * @return EDD_SL_Plugin_Updater object instance */ public static function add($plugin_file, $option_key = '', $api_data = array()) { // Include the updater if we haven't self::include_updater(); $base_name = plugin_basename($plugin_file); if ($option_key) { // Add to the list of keys to save license statuses AppPresser_Admin_Settings::$license_keys[$option_key] = $base_name; } $api_data = wp_parse_args($api_data, array('author' => self::AUTHOR, 'url' => self::STORE_URL, 'license' => trim(appp_get_setting($option_key)))); $api_url = $api_data['url']; unset($api_data['url']); // Init updater $updater = new EDD_SL_Plugin_Updater($api_url, $plugin_file, $api_data); // Add passed-in vars to the object since the vars are private (derp). $updater->public = $api_data + array('api_url' => $api_url, 'plugin_file' => $plugin_file); // Add this updater instance to our array self::$updaters['plugins'][$base_name] = $updater; return $updater; }
/** * Adds AppPresser Core's settings * @since 1.0.0 */ public function add_settings() { // Main tab self::add_setting_tab(__('AppPresser', 'apppresser'), 'general'); self::add_setting_label(__('AppPresser Core Settings', 'apppresser')); // For now... if (appp_get_setting('mobile_browser_theme_switch')) { self::add_setting('mobile_browser_theme_switch', __('Load AppPresser for mobile browsers', 'apppresser'), array('type' => 'checkbox', 'helptext' => __('Display AppPresser in mobile browsers such as Safari and Chrome, instead of your normal theme.', 'apppresser'))); } self::add_setting('admin_theme_switch', __('Load AppPresser for Admins Only', 'apppresser'), array('type' => 'checkbox', 'helptext' => __('Check this if you want to test your AppPresser app without loading it for visitors to your site.', 'apppresser'), 'description' => __('(for testing purposes)', 'apppresser'))); self::add_setting('appp_theme', __('App-only theme', 'apppresser'), array('type' => 'select', 'options' => $this->themes, 'helptext' => __('Select which theme you want to be loaded inside the app, such as the AppPresser theme.', 'apppresser'), 'description' => __('Must be enabled above.', 'apppresser'))); self::add_setting('customizer_link', __('App Design', 'apppresser'), array('type' => 'paragraph', 'helptext' => __('Opens the customizer to customize the look of your app.', 'apppresser'), 'value' => __('<span></span>', 'apppresser'), 'description' => __('Click here to customize app colors, menus, homepage & more.', 'apppresser'))); self::add_setting('appp_pg_version', __('Phonegap Version', 'apppresser'), array('type' => 'select', 'options' => $this->phonegap_versions(), 'helptext' => __('Select the Phonegap Version of your app.', 'apppresser'), 'description' => __('Select Phonegap Version.', 'apppresser'))); self::add_setting('appp_show_on_front', __('Use a unique homepage for your app.', 'apppresser'), array('type' => 'radio', 'options' => array('latest_posts' => 'Your latest posts', 'static_page' => 'A static page (select below)'), 'helptext' => __('SAllows you to specify which page users will see first when they load up you AppPresser app.', 'apppresser'), 'description' => __('Select homepage option.', 'apppresser'))); self::add_setting('appp_home_page', '', array('description' => __('Start typing to search for a page, or enter a page ID.', 'apppresser'))); /*$menus = array( 'option-none' => __( '-- select --', 'apppresser' ) ); foreach ( (array) $this->nav_menus as $menu ) { $menus[ $menu->term_id ] = $menu->name; } // Register main menu setting self::add_setting( 'menu', __( 'Main App Menu', 'apppresser' ), array( 'type' => 'select', 'options' => $menus, 'helptext' => __( 'Use a custom main menu inside your app, different from your main site.', 'apppresser' ), ) ); // Register secondary menu setting self::add_setting( 'secondary_menu', __( 'Secondary App Menu', 'apppresser' ), array( 'type' => 'select', 'options' => $menus, 'helptext' => __( 'Use a custom secondary menu inside your app (the top right dropdown in the header).', 'apppresser' ), ) );*/ add_action('apppresser_tab_buttons_general', array($this, 'help_link')); }
/** * If customizing apppresser theme, makes sure we're viewing the right theme. * @since 1.0.7 */ public function redirect_correct_appp_theme() { wp_redirect(esc_url(add_query_arg('theme', appp_get_setting('appp_theme')))); }
/** * AppPresser set the default home page based on the APPP settings * @since 1.0.0 * @return int page ID stored in APPP settings */ public function pre_page_on_front() { $this->theme = wp_get_theme(); if ($this->theme->template == $this->maybe_switch() && !is_admin()) { return appp_get_setting('appp_home_page'); } return false; }