コード例 #1
0
function mgm_filter_scripts()
{
    global $mgm_scripts, $wp_scripts;
    //mgm_scripts is the array to hold mgm scripts loaded at runtime.
    if (is_array($wp_scripts->registered) && is_array($mgm_scripts)) {
        $mgm_scripts = array_unique($mgm_scripts);
        foreach ($wp_scripts->registered as $key => $obj) {
            $file = basename($obj->src);
            if (in_array($file, $mgm_scripts)) {
                //This will prevent library scripts from loading multiple times
                wp_deregister_script($key);
            }
        }
    }
    //specifically remove jquery files:
    //incomplete
    //return;
    $arr_jquery = array();
    $arr_exceptions = array('jquery.ajaxfileupload.js', 'jquery-ui-1.7.3.min.js', 'jquery.form.js', 'jquery.scrollTo-min.js', 'jquery.validate.pack.js', 'jquery.corner.js');
    //issue #1589
    if (mgm_is_plugin_active('simple-press/sp-control.php')) {
        $arr_sp_exceptions = array('jquery.ui.plupload.js', 'jqueryFileTree.js', 'jquery.captcha.js', 'jquery.js', 'jquery.tools.min.js');
        $arr_exceptions = array_merge($arr_exceptions, $arr_sp_exceptions);
    }
    //issue #1637
    if (function_exists('wp_get_theme') && strtolower(wp_get_theme()) == 'oxygen') {
        $arr_ox_theme_exceptions = array('jquery.masonry.min.js');
        $arr_exceptions = array_merge($arr_exceptions, $arr_ox_theme_exceptions);
    }
    //issue #1670
    if (function_exists('wp_get_theme') && strtolower(wp_get_theme()) == 'holly eriksson') {
        $arr_he_theme_exceptions = array('jquery.prettyPhoto.js', 'jquery.flexslider-min.js', 'jquery.tweet.js');
        $arr_exceptions = array_merge($arr_exceptions, $arr_he_theme_exceptions);
    }
    //issue #1677
    if (function_exists('wp_get_theme') && strtolower(wp_get_theme()) == 'salutation') {
        $arr_fb_theme_exceptions = array('jquery.colorbox-min.js');
        $arr_exceptions = array_merge($arr_exceptions, $arr_fb_theme_exceptions);
    }
    //issue #1695
    if (function_exists('wp_get_theme') && strtolower(wp_get_theme()) == 'cgbloggernew') {
        $arr_cgblogger_theme_exceptions = array('jquery.js');
        $arr_exceptions = array_merge($arr_exceptions, $arr_cgblogger_theme_exceptions);
    }
    //issue #1717
    if (mgm_is_plugin_active('easy-digital-downloads/easy-digital-downloads.php') || mgm_is_plugin_active('fusion-core/fusion-core.php')) {
        $arr_edd_exceptions = array('chosen.jquery.min.js');
        $arr_exceptions = array_merge($arr_exceptions, $arr_edd_exceptions);
    }
    //loop
    foreach ($wp_scripts->registered as $key => $obj) {
        $file = basename($obj->src);
        //if(preg_match('/jquery./', $file) || preg_match('/jquery-/', $file)) {
        if (preg_match('/jquery./', $file) || preg_match('/jquery-/', $file)) {
            if (in_array($file, $arr_jquery) && !in_array($file, $arr_exceptions)) {
                wp_deregister_script($key);
            } else {
                $arr_jquery[] = $file;
            }
        }
    }
}
コード例 #2
0
/**
 * callback to replace buddypress url with register url
 *
 * @param string $redirect
 * @return string $redirect
 */
function mgm_bp_register_url($redirect)
{
    // check
    if (mgm_is_plugin_active('buddypress/bp-loader.php')) {
        // getpages
        $bp_pages = get_option('bp-pages');
        // check
        if (isset($bp_pages['register']) && !empty($bp_pages['register'])) {
            // list
            list($url, $qs) = explode('?', $redirect, 2);
            // trim
            $url = trailingslashit($url);
            // compare with bussypress register url
            // if same replace base url with custom register url
            if ($url == trailingslashit(get_permalink($bp_pages['register']))) {
                // replace buddy press register url with register url
                $redirect = trailingslashit(mgm_get_custom_url('register'));
                // set qs back
                if (!empty($qs)) {
                    $redirect .= '?' . $qs;
                }
            }
        }
    }
    // return
    return $redirect;
}
コード例 #3
0
 function general()
 {
     // local
     extract($_POST);
     // log
     // mgm_log(mgm_array_dump($_POST,true));
     // update
     if (isset($settings_update) && !empty($settings_update)) {
         // get system object
         $system_obj = mgm_get_class('system');
         // boolean flds
         $b_flds = array('reminder_days_incremental', 'use_ssl_paymentpage', 'enable_autologin', 'aws_enable_s3', 'enable_googleanalytics', 'enable_post_url_redirection', 'enable_facebook', 'enable_process_inactive_users', 'enable_guest_lockdown', 'share_registration_url_with_bp', 'aws_enable_qsa');
         // hidden flds
         $h_flds = array('login_redirect_url', 'logout_redirect_url', 'category_access_redirect_url', 'autologin_redirect_url', 'googleanalytics_key', 'facebook_id', 'facebook_key', 'guest_lockdown_redirect_url');
         // array fields
         // $a_flds = array('guest_content_purchase_options_links');
         // update if set
         foreach ($system_obj->setting as $k => $v) {
             // set default boolean fields
             if (in_array($k, $b_flds)) {
                 $_POST[$k] = isset($_POST[$k]) ? $_POST[$k] : 'N';
             }
             // set default hidden fields
             if (in_array($k, $h_flds)) {
                 $_POST[$k] = isset($_POST[$k]) ? $_POST[$k] : '';
             }
             // set var
             if (isset($_POST[$k])) {
                 // array
                 if (is_array($_POST[$k])) {
                     $system_obj->setting[$k] = (array) $_POST[$k];
                 } else {
                     $system_obj->setting[$k] = addslashes($_POST[$k]);
                 }
             }
             // aws_qsa_expires
             if ('aws_qsa_expires' == $k) {
                 $system_obj->setting[$k] = (int) $_POST['aws_qsa_expires_unit'] . ' ' . $_POST['aws_qsa_expires_expr'];
             }
             // multiple login time span
             if ('multiple_login_time_span' == $k) {
                 $system_obj->setting[$k] = (int) $_POST['multiple_login_time_span_unit'] . ' ' . $_POST['multiple_login_time_span_expr'];
             }
         }
         // update
         $system_obj->save();
         // affiliate - issue #1758
         if (isset($_POST['use_affiliate_link']) == 'Y' && isset($_POST['affiliate_id'])) {
             update_option('mgm_affiliate_id', intval($_POST['affiliate_id']));
         } else {
             delete_option('mgm_affiliate_id');
         }
         // extend dir
         if (!empty($_POST['extend_dir']) && $_POST['extend_dir'] != get_option('mgm_extend_dir')) {
             // verify dir
             if (is_dir(ABSPATH . $_POST['extend_dir'])) {
                 // update
                 update_option('mgm_extend_dir', $_POST['extend_dir']);
             } else {
                 // error
                 $error = 'The Extend Directory path is not valid! Please create the directory first and update settings.';
             }
         } else {
             // verify
             if (empty($_POST['extend_dir']) || !is_dir(ABSPATH . get_option('mgm_extend_dir'))) {
                 // error
                 $error = 'The Extend Directory path is not valid! Reverting back to default.';
                 // update to default
                 update_option('mgm_extend_dir', trailingslashit(PLUGINDIR . '/magicmembers/extend'));
             }
         }
         // message
         if (isset($error)) {
             $reponse = array('status' => 'error', 'message' => __($error, 'mgm'));
         } else {
             $reponse = array('status' => 'success', 'message' => __('General settings successfully updated.', 'mgm'));
         }
         // message
         echo json_encode($reponse);
         // return
         return;
     }
     // data
     $data = array();
     // duration_exprs
     $data['qsa_expr'] = array('HOUR' => __('HOUR', 'mgm'), 'DAY' => __('DAY', 'mgm'), 'WEEK' => __('WEEK', 'mgm'), 'MONTH' => __('MONTH', 'mgm'), 'YEAR' => __('YEAR', 'mgm'));
     // system
     $data['system_obj'] = mgm_get_class('system');
     // bp
     $data['bp_active'] = mgm_is_plugin_active('buddypress/bp-loader.php');
     // load template view
     $this->load->template('settings/general', array('data' => $data));
 }
コード例 #4
0
/**
 * Check transaction page content is to be loaded if buddypress and mgm shares registration page.
 */
function mgm_is_bp_registration()
{
    // If Buddypress is enabled
    if (mgm_is_plugin_active('buddypress/bp-loader.php')) {
        // If setting is enabled - is registration urls same for BP and MGM
        if (bool_from_yn(mgm_get_setting('share_registration_url_with_bp'))) {
            // if current url is registration url and transaction page is to be loaded
            if (false !== strpos(mgm_current_url(), untrailingslashit(mgm_get_setting('register_url'))) && isset($_GET['method']) && preg_match('/^payment/', $_GET['method'])) {
                return true;
            }
        }
    }
    return false;
}