Plugin Directory

Changeset 834419


Ignore:
Timestamp:
01/07/2014 04:00:16 PM (12 years ago)
Author:
apppresser
Message:

1.0.4

  • Extensions submenu highlighting available for AppPresser add-ons.
  • Addressed some pre-PHP 5.3 notices.
  • Bug Fix: White-screen on the front end if selecting a theme in the "App only theme?" setting that does not support AppPresser. An error will now be shown.
  • Improvement: appp_get_setting() now accepts a fallback option like get_option().
Location:
apppresser/trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • apppresser/trunk/apppresser.php

    r825882 r834419  
    66Text Domain: apppresser
    77Domain Path: /languages
    8 Version: 1.0.3
     8Version: 1.0.4
    99Author: AppPresser Team
    1010Author URI: http://apppresser.com
     
    3030class AppPresser {
    3131
    32     const VERSION           = '1.0.3';
     32    const VERSION           = '1.0.4';
    3333    const SETTINGS_NAME     = 'appp_settings';
    3434    public static $settings = 'false';
     
    9191        // Hook in all our important pieces
    9292        add_action( 'plugins_loaded', array( $this, 'includes' ) );
    93         add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
     93        add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ), 8 );
    9494        add_action( 'wp_head', array( $this, 'do_appp_script' ), 1 );
    9595
     
    190190    }
    191191
     192    /**
     193     * Strip query var from enqueued cordova script
     194     * @since  1.0.3
     195     * @param  string  $src URL
     196     * @return string       Modified URL
     197     */
    192198    function remove_query_arg( $src ) {
    193199        if ( false !== strpos( $src, 'cordova.js' ) )
     
    199205     * Utility method for getting our plugin's settings
    200206     * @since  1.0.0
    201      * @param  string $key Optional key to get a specific option
    202      * @return mixed       Array of all options, a specific option, or false if specific option not found.
    203      */
    204     public static function settings( $key = false ) {
     207     * @param  string $key      Optional key to get a specific option
     208     * @param  string $fallback Fallback option if none is found.
     209     * @return mixed            Array of all options, a specific option, or false if specific option not found.
     210     */
     211    public static function settings( $key = false, $fallback = false ) {
    205212        if ( self::$settings === 'false' ) {
    206213            self::$settings = get_option( self::SETTINGS_NAME );
     
    209216            $setting = isset( self::$settings[ $key ] ) ? self::$settings[ $key ] : false;
    210217            // Override value or supply fallback
    211             return apply_filters( 'apppresser_setting_default', $setting, $key, self::$settings );
     218            $return = apply_filters( 'apppresser_setting_default', $setting, $key, self::$settings, $fallback );
     219            return $return ? $return : $fallback;
     220
    212221        }
    213222        return self::$settings;
     
    246255 * Function wrapper for AppPresser::settings()
    247256 * @since  1.0.0
    248  * @param  string $key Optional key to get a specific option
    249  * @return mixed       Array of all options, a specific option, or false if specific option not found.
     257 * @param  string $key      Optional key to get a specific option
     258 * @param  string $fallback Fallback option if none is found.
     259 * @return mixed            Array of all options, a specific option, or false if specific option not found.
    250260 */
    251 function appp_get_setting( $key = false ) {
    252     return AppPresser::settings( $key );
     261function appp_get_setting( $key = false, $fallback = false ) {
     262    return AppPresser::settings( $key, $fallback );
    253263}
  • apppresser/trunk/inc/admin-settings.php

    r825875 r834419  
    1616    public static $instance       = null;
    1717    public static $page_slug      = 'apppresser_settings';
     18    public static $extensions_slug       = 'apppresser_sub_extensions';
    1819    public static $help_slug      = 'apppresser_sub_help_support';
    1920    public static $menu_slug      = '';
     21    public static $extensions_menu_slug  = '';
    2022    public static $help_menu_slug = '';
    2123    public static $image_inputs   = array();
     
    4143     */
    4244    function __construct() {
    43         add_action( 'admin_menu', array( $this, 'plugin_menu' ) );
     45        add_action( 'admin_menu', array( $this, 'plugin_menu' ), 9 );
    4446        add_filter( 'sanitize_option_'. AppPresser::SETTINGS_NAME, array( $this, 'maybe_reset_license_statuses' ), 99 );
    4547        add_action( 'admin_init', array( $this, 'register_settings' ) );
     
    8385     */
    8486    function plugin_menu() {
    85         // Create main menu
     87        // Create main menu and settings page
    8688        self::$menu_slug = add_menu_page( __( 'AppPresser', 'apppresser' ), __( 'AppPresser', 'apppresser' ), 'manage_options', self::$page_slug, array( $this, 'settings_page' ) );
    8789        // Create submenu items
     90
     91        // Extensions page
     92        self::$extensions_menu_slug = add_submenu_page( self::$page_slug, __( 'Extensions', 'apppresser' ), __( 'Extensions', 'apppresser' ), 'manage_options', self::$extensions_slug, array( $this, 'extensions_page' ) );
     93        // Help page
    8894        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' ) );
    8995
    90         // enqueue our js
    9196        add_action( 'admin_head-' . self::$menu_slug, array( $this, 'admin_head' ) );
    92         add_action( 'admin_print_scripts-' . self::$menu_slug, array( $this, 'admin_scripts' ) );
     97
     98        // enqueue
     99        foreach ( array( self::$menu_slug, self::$extensions_menu_slug, self::$help_menu_slug ) as $slug )
     100            add_action( 'admin_print_scripts-' . $slug, array( $this, 'admin_scripts' ) );
    93101
    94102    }
     
    102110        wp_enqueue_script( 'appp-admin', self::$js_url . 'appp-admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-tooltip' ), self::VERSION );
    103111        wp_enqueue_style( 'jquery-ui-smoothness', self::$css_url . 'smoothness/smoothness.custom.min.css' );
    104     }
    105 
    106     /**
    107      * Apply some settings for our tooltip hover spot
     112        wp_enqueue_style( 'appp-admin-styles', self::$css_url . 'appp-admin-styles.css', null, self::VERSION.time() );
     113    }
     114
     115    /**
     116     * Easy hook for adding to the admin_head on the AppPresser settings page
    108117     * @since  1.0.0
    109118     */
    110119    function admin_head() {
    111         ?>
    112         <style>.apppresser_settings .help { background: rgb(220,220,220); border-radius: 50%; color: rgb(0, 0, 0); display: inline-block; height: 15px; margin-left: 5px; text-align: center; text-decoration: none; text-shadow: none; width: 15px; font-weight: normal; } .apppresser_settings.mp6 .help { line-height: 15px; } .form-table .appp-section-title { padding-bottom: 0; } .appp-section-title h3 { margin: 0; } .apppresser_settings .form-table { display: none; padding-top: .6em; } .apppresser_settings .form-table.nav-tab-active { display: block; } .appp-ajax-results-help { display:none; margin: 10px 0 -8px 7px !important; } .submit .appp-tabs { margin: 0 10px; display: none; } .appp-tabs.nav-tab-active { display: inline; } .license_key.description span {
    113             color: white; display: block; background: #49C749; text-align: center; font-weight: bold; font-style: normal; text-transform: uppercase; margin: -5px 1px; width: 25em; } .mp6 .license_key.description span { font-size: 14px; } .license_key.description span.inactive {
    114             background: #F14949; } .license_key.description span.inactive a { color: #fff; }
    115         </style>
    116         <?php
    117 
    118         // Easy hook for adding to the admin_head on the AppPresser settings page
    119120        do_action( 'appp_admin_settings_head', self::run() );
    120121    }
     
    207208        <div class="wrap <?php echo $class; ?>">
    208209            <?php
    209             $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : array_shift( array_keys( self::$admin_tabs ) );
     210            $keys = array_keys( self::$admin_tabs );
     211            $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : array_shift( $keys );
    210212            $current_tab = preg_replace('/tab-/', '', $current_tab, 1 );
    211213
     
    264266        self::add_setting_tab( __( 'AppPresser', 'apppresser' ), 'general' );
    265267        self::add_setting_label( __( 'AppPresser Core Settings', 'apppresser' ) );
    266         self::add_setting( 'mobile_browser_theme_switch', __( 'Load AppPresser for mobile browsers', 'apppresser' ), array( 'type' => 'checkbox', 'helptext' => __( 'Whether or not you want to load the application layer for mobile users.', 'apppresser' ) ) );
     268
     269        // For now...
     270        if ( appp_get_setting( 'mobile_browser_theme_switch' ) ) {
     271            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' ) ) );
     272        }
     273
    267274        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' ) ) );
    268         self::add_setting( 'appp_theme', __( 'Admin only theme', 'apppresser' ), array( 'type' => 'select', 'options' => $this->themes, 'helptext' => __( 'Select which theme you want to be loaded with your testing of AppPresser.', 'apppresser' ), 'description' => __( 'must be enabled above', 'apppresser' ) ) );
     275        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' ) ) );
    269276        self::add_setting( 'appp_home_page', __( 'Use a unique homepage for your app.', 'apppresser' ), array( 'helptext' => __( 'Allows you to specify which page users will see first when they load up you AppPresser app.', 'apppresser' ), 'description' => __( 'Start typing to search for a page', 'apppresser' ) ) );
    270277
     
    310317
    311318    /**
    312      * Help and Support settings page
    313      * @since  1.0.0
    314      */
    315     function help_support_page() {
    316         $class = self::$page_slug;
    317         $class .= self::is_mp6() ? ' mp6' : '';
    318         ?>
    319         <div class="wrap <?php echo $class; ?>">
    320             <h2>AppPresser <?php _e( 'Help and Support', 'apppresser' ); ?></h2>
    321             <p><strong><?php _e( 'Resources', 'apppresser' ); ?>:</strong> <a href="https://github.com/WebDevStudios/AppPresser/" target="_blank">AppPresser <?php _e( 'Core on Github', 'apppresser' ); ?></a> | <a href="http://wordpress.org/support/plugin/apppresser" target="_blank"><?php _e( 'Support Forums', 'apppresser' ); ?></a> | <a href="http://apppresser.com/docs/" target="_blank">AppPresser <?php _e( 'Documentation', 'apppresser' ); ?></a></p>
    322             <p><strong>AppPresser <?php _e( 'Online', 'apppresser' ); ?>:</strong> <a href="http://twitter.com/apppresser" target="_blank"><?php _e( 'Twitter', 'apppresser' ); ?></a> | <a href="http://facebook.com/apppresser" target="_blank"><?php _e( 'Facebook', 'apppresser' ); ?></a> | <a href="http://youtube.com/user/apppresser" target="_blank"><?php _e( 'YouTube', 'apppresser' ); ?></a></p>
    323             <h3><?php _e( 'About AppPresser', 'apppresser' ); ?></h3>
    324             <p><?php _e( 'AppPresser was created by Scott Bolinger, Brad Williams, Brian Messenlehner, and Lisa Sabin-Wilson', 'apppresser' ); ?>.</p>
    325         </div>
    326         <?php
    327     }
    328 
    329     /**
    330319     * Adds a setting section to AppPresser's settings
    331320     * @since  1.0.0
     
    337326    public static function add_setting( $key, $label, $args = array() ) {
    338327
     328        $keys = array_keys( self::$admin_tabs );
    339329        $defaults = array(
    340330            'type'        => 'text',
     
    342332            'description' => '',
    343333            'options'     => array(),
    344             'tab'         => array_shift( array_keys( self::$admin_tabs ) ),
     334            'tab'         => array_shift( $keys ),
    345335            'echo'        => false,
    346336        );
     
    518508    }
    519509
     510    /**
     511     * Help and Support settings page
     512     * @since  1.0.0
     513     */
     514    function help_support_page() {
     515        $class = self::$page_slug;
     516        $class .= self::is_mp6() ? ' mp6' : '';
     517        ?>
     518        <div class="wrap <?php echo $class; ?>">
     519            <h2>AppPresser <?php _e( 'Help and Support', 'apppresser' ); ?></h2>
     520            <p><strong><?php _e( 'Resources', 'apppresser' ); ?>:</strong> <a href="https://github.com/WebDevStudios/AppPresser/" target="_blank">AppPresser <?php _e( 'Core on Github', 'apppresser' ); ?></a> | <a href="http://wordpress.org/support/plugin/apppresser" target="_blank"><?php _e( 'Support Forums', 'apppresser' ); ?></a> | <a href="http://apppresser.com/docs/" target="_blank">AppPresser <?php _e( 'Documentation', 'apppresser' ); ?></a></p>
     521            <p><strong>AppPresser <?php _e( 'Online', 'apppresser' ); ?>:</strong> <a href="http://twitter.com/apppresser" target="_blank"><?php _e( 'Twitter', 'apppresser' ); ?></a> | <a href="http://facebook.com/apppresser" target="_blank"><?php _e( 'Facebook', 'apppresser' ); ?></a> | <a href="http://youtube.com/user/apppresser" target="_blank"><?php _e( 'YouTube', 'apppresser' ); ?></a></p>
     522            <h3><?php _e( 'About AppPresser', 'apppresser' ); ?></h3>
     523            <p><?php _e( 'AppPresser was created by Scott Bolinger, Brad Williams, Brian Messenlehner, and Lisa Sabin-Wilson', 'apppresser' ); ?>.</p>
     524        </div>
     525        <?php
     526    }
     527
     528    /**
     529     * AppPresser extensions page output
     530     * @since  1.0.4
     531     */
     532    function extensions_page() {
     533        $class = self::$page_slug;
     534        $class .= self::is_mp6() ? ' mp6' : '';
     535        ?>
     536        <div class="wrap <?php echo $class; ?>">
     537            <h2><?php printf( 'AppPresser ' .__( 'Extensions &nbsp;&mdash;&nbsp; %s', 'apppresser' ), '<a href="http://apppresser.com/extensions/?ref=appp" class="button-primary" target="_blank">' . __( 'Browse All Extensions', 'apppresser' ) . '</a>' ); ?></h2>
     538            <p><?php _e( 'These extensions extend the functionality of AppPresser.', 'apppresser' ); ?></p>
     539
     540         <?php
     541            // Attempt to pull back our cached feed
     542            $feed = get_transient( 'appp_extensions_feed' );
     543            $fallback = '<div class="error"><p>' . __( 'There was an error retrieving the extensions list. Please try again later.', 'apppresser' ) . '</div>';
     544
     545            // If we don't have a cached feed, pull back fresh data
     546            if ( empty( $feed ) ) {
     547                // Retrieve and parse our feed
     548                $feed = wp_remote_get( 'http://apppresser.com/?feed=addons', array( 'sslverify' => false ) );
     549                if ( ! is_wp_error( $feed ) ) {
     550                    if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) {
     551                        $feed = wp_remote_retrieve_body( $feed );
     552                        // Cache our feed for 1 hour
     553                        set_transient( 'appp_extensions_feed', $feed, HOUR_IN_SECONDS );
     554                    }
     555                }
     556            }
     557
     558            // display the feed or error message
     559            echo $feed && ! is_wp_error( $feed ) ? $feed : $fallback;
     560            ?>
     561     </div>
     562     <?php
     563
     564    }
     565
     566    /**
     567     * Returns url to the AppPresser settings page
     568     * @since  1.0.4
     569     * @return string  AppPresser settings page url
     570     */
     571    public static function url() {
     572        return add_query_arg( 'page', self::$page_slug, admin_url( 'admin.php' ) );
     573    }
     574
    520575}
    521576AppPresser_Admin_Settings::run();
  • apppresser/trunk/inc/theme-switcher.php

    r825873 r834419  
    3434        add_filter( 'pre_option_show_on_front', array( $this, 'pre_show_on_front' ) );
    3535        add_filter( 'pre_option_page_on_front', array( $this, 'pre_page_on_front' ) );
     36        add_action( 'template_redirect', array( $this, 'check_appaware' ) );
     37
    3638        $this->theme = wp_get_theme();
    3739    }
     
    4648        if ( is_admin() )
    4749            return;
    48 
    4950        // Set cookie from querystring if request is coming from an app
    5051        if ( self::is_app() ) {
     
    116117    }
    117118
     119    /**
     120     * Checks if selected theme supports apppresser. Theme should have `add_theme_support( 'apppresser' );`
     121     * If not, dies with a message and link to the AppPresser settings page.
     122     *
     123     * @since  1.0.4
     124     */
     125    public function check_appaware() {
     126        if ( ! current_theme_supports( 'apppresser' ) ) {
     127            wp_die( '<p style="text-align:center;font-size:1.1em"><strong>'. __( 'This theme does not support AppPresser.', 'apppresser' ) . '</strong><br>' . sprintf( __( 'Please change your %s to an AppAware theme.', 'apppresser' ), '<a href="'. AppPresser_Admin_Settings::url() .'">'. __( '"App only theme?" setting', 'apppresser' ) .'</a>' ) .'</p>' );
     128        }
     129    }
     130
     131
    118132}
    119133AppPresser_Theme_Switcher::go();
  • apppresser/trunk/js/appp.js

    r825873 r834419  
    1919    apppCore.log( 'apppCore', apppCore );
    2020
    21     if ( ! apppCore.is_appp_true && ! apppCore.QueryVars('appp') && apppCore.isApp() && apppCore.isMobile() ) {
     21    if ( ! apppCore.is_appp_true && ! apppCore.QueryVars('appp') && ! apppCore._isApp && apppCore.isApp() && apppCore.isMobile() ) {
    2222
    2323        // Redirect to query var-ed version
  • apppresser/trunk/js/appp.min.js

    r825873 r834419  
    11window.apppCore=typeof window.apppCore!=="undefined"?window.apppCore:{};apppCore.init=function(){apppCore._isApp=typeof apppCore.mobile_browser_theme_switch!=="undefined"&&apppCore.mobile_browser_theme_switch==="on"?true:"not set";
    2 apppCore.queryVars=false;apppCore.log("apppCore",apppCore);if(!apppCore.is_appp_true&&!apppCore.QueryVars("appp")&&apppCore.isApp()&&apppCore.isMobile()){window.location.href=apppCore.AddQueryVar(window.location.href,"appp",1);
     2apppCore.queryVars=false;apppCore.log("apppCore",apppCore);if(!apppCore.is_appp_true&&!apppCore.QueryVars("appp")&&!apppCore._isApp&&apppCore.isApp()&&apppCore.isMobile()){window.location.href=apppCore.AddQueryVar(window.location.href,"appp",1);
    33}else{if(apppCore.QueryVars("appp")){apppCore.log("apppCore.is_appp_true",!!apppCore.is_appp_true);apppCore.log("apppCore.QueryVars('appp')",!!apppCore.QueryVars("appp"));
    44apppCore.log("apppCore.isApp()",!!apppCore.isApp());apppCore.log("apppCore.isMobile()",!!apppCore.isMobile());}}};apppCore.ReadCookie=function(b){var e=b+"=";
  • apppresser/trunk/readme.txt

    r825873 r834419  
    55Requires at least: 3.5
    66Tested up to: 3.8
    7 Stable tag: 1.0.3
     7Stable tag: 1.0.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9090== Changelog ==
    9191
     92= 1.0.4 =
     93* Extensions submenu highlighting available AppPresser add-ons
     94
    9295= 1.0.3 =
    9396* Bug Fix: `plugins_loaded` firing too early causing conflicts with other plugins.
     
    109112== Upgrade Notice ==
    110113
     114= 1.0.4 =
     115* Extensions submenu highlighting available AppPresser add-ons
     116
    111117= 1.0.3 =
    112118* Bug Fix: `plugins_loaded` firing too early causing conflicts with other plugins.
Note: See TracChangeset for help on using the changeset viewer.