コード例 #1
0
ファイル: ym-index.php プロジェクト: AdultStack/ap-members
}
// Database updates can be called on this hook
do_action('ym_pre_admin_loader');
get_currentuserinfo();
global $current_user, $ym_auth, $ym_res, $ym_sys;
$ym_page = ym_get('ym_page');
if ($ym_auth->ym_check_key()) {
    if (!ym_tos_checks()) {
        // no TOS stuff in progress
        echo '<div class="wrap"><h2>' . YM_ADMIN_NAME . '</h2>';
        // wizard
        ym_wizard_render();
        // loop
        ym_admin_menu();
        echo '<div style="clear: both; padding: 0px; margin: 0px;">';
        ym_admin_loader();
        echo '</div>';
        ym_admin_menu_end();
        // end
        echo '</div>';
    }
} else {
    global $ym_version_resp;
    ym_check_version(true);
    // ym conf hook
    if (!isset($_POST['activate_plugin'])) {
        ym_check_for_ymconf();
    }
    $auth_key_result = false;
    // no key
    if (ym_post('activate_plugin', false) && ym_post('registration_email', false)) {
コード例 #2
0
ファイル: ym.php プロジェクト: AdultStack/ap-members
function ym_loaded()
{
    // last globals
    global $current_user, $ym_user;
    get_currentuserinfo();
    if (is_user_logged_in()) {
        // as the user is logged in....
        $ym_user = new YourMember_User($current_user->ID);
    } else {
        // blank one
        $ym_user = new YourMember_User();
    }
    global $wpdb, $ym_auth, $ym_dl_db, $ym_dl_post_assoc, $ym_sys, $plugin_file;
    global $wp_upload, $ym_upload_root, $ym_upload_url;
    if (ym_get('ym_go') == 'support') {
        header('Location: ' . YM_SUPPORT_LINK);
        exit;
    }
    // TODO: tidy all these calls up again
    //Localization
    add_action('init', 'ym_load_lang');
    // admin bar
    add_action('init', 'ym_admin_nav');
    add_action('admin_bar_menu', 'ym_admin_bar', 90);
    // context help (help in the top right)
    if (is_admin()) {
        add_action('ym_pre_admin_loader', 'ym_database_updater', 10, 1);
        // interrupt?
        if (ym_request('do_munch')) {
            ym_admin_loader();
            exit;
        }
        // main drag
        add_action('admin_menu', 'ym_admin_page');
        //Plugin Panel Hooks
        add_filter('plugin_action_links', 'ym_action_link', 10, 2);
        // user edit
        add_action('user_edit_form_tag', 'ym_form_enctype');
        // conf bypasses
        ym_conf_bypass();
        //		add_action('load-toplevel_page_ym/admin/ym-index', 'ym_context_help');
        add_action('load-toplevel_page_' . YM_ADMIN_FUNCTION, 'ym_context_help');
        add_action('load-your-members_page_' . YM_ADMIN_DIR . 'ym-about', 'ym_context_help');
    } else {
        // SSL
        add_action('init', 'ym_go_ssl');
        add_action('posts_selection', 'ym_go_ssl_pages');
        if ($ym_sys->enable_metered) {
            add_action('init', 'ym_check_metered_access');
        }
        add_action('get_footer', 'ym_affiliate_link');
    }
    // call version check
    ym_check_version();
    if ($ym_auth->ym_check_key()) {
        $wp_upload = wp_upload_dir();
        if ($wp_upload['error']) {
            if (is_admin() && ym_get('page') == YM_ADMIN_FUNCTION && !ym_request('ym_page')) {
                echo '<div id="message" class="error"><p>' . $wp_upload['error'] . '</p></div>';
            }
        } else {
            $ym_upload_root = $wp_upload['path'];
            $ym_upload_url = $wp_upload['url'];
        }
        ym_create_log_constants();
        //Must be first for any logging that occurs from hereonin
        ym_suppress_enclosure_check();
        add_action('mod_rewrite_rules', 'ym_block_wp_login_action_register');
        add_action('admin_init', 'ym_block_wp_login_action_register_flush');
        if (!is_admin()) {
            ym_download_response();
            //checks for a download id in the url
            global $ym_manage_access;
            $ym_manage_access = new YourMember_Manage_Access();
            if ($ym_sys->protect_mode) {
                add_action('template_redirect', array($ym_manage_access, 'exit_check'));
            }
            add_shortcode('private', 'ym_shortcode_parse');
            add_shortcode('no_access', 'ym_shortcode_parse');
            add_shortcode('user_has_access', 'ym_shortcode_parse');
            add_shortcode('ym_user_profile', 'ym_edit_custom_field_standalone');
            add_shortcode('ym_rss_token', 'ym_get_rss_token');
            add_shortcode('ym_upgrade', 'ym_shortcode_parse');
            add_shortcode('ym_packs', 'ym_shortcode_parse');
            add_shortcode('private_or', 'ym_shortcode_parse');
            add_shortcode('private_and', 'ym_shortcode_parse');
            add_shortcode('ym_membership_content', 'ym_membership_content_shortcode');
            // TODO: Deprecate 11.0.6
            add_shortcode('user_account_is', 'ym_shortcode_parse');
            add_shortcode('private_username_is', 'ym_shortcode_parse');
            // Replace with
            add_shortcode('ym_user_is', 'ym_user_is');
            add_shortcode('ym_user_is_not', 'ym_user_is_not');
            add_shortcode('ym_user_custom_is', 'ym_user_custom_is');
            add_shortcode('ym_user_custom_is_not', 'ym_user_custom_is_not');
            add_shortcode('ym_profile', 'ym_get_user_profile');
            add_shortcode('ym_purchase_history', 'ym_get_user_purchase_history_shortcode');
            add_shortcode('ym_gateway_cancel', 'ym_get_user_unsub_button_gateway');
            add_shortcode('ym_gravatar', 'ym_gravatar_render');
            // start content
            // buy now
            add_shortcode('ym_buy_content', 'ym_buy_button_content');
            add_filter('the_content', 'ym_buy_button_content_filter', 1, 1);
            add_shortcode('ym_buy_bundle', 'ym_buy_button_bundle');
            add_filter('the_content', 'ym_buy_button_bundle_filter', 1, 1);
            // end buy now
            // indexy
            add_shortcode('ym_all_content', 'ym_get_all_content_buttons');
            add_shortcode('ym_all_bundles', 'ym_get_all_bundle_buttons');
            add_shortcode('ym_featured_content', 'ym_get_featured_content_buttons');
            // end indexy
            add_shortcode('ym_content_units_left', 'ym_content_units_left');
            add_shortcode('ym_bundle_units_left', 'ym_bundle_units_left');
            //pass ID
            add_shortcode('ym_content_units_sold', 'ym_content_units_sold');
            add_shortcode('ym_bundle_units_sold', 'ym_bundle_units_sold');
            //pass ID
            add_shortcode('ym_content_units_limit', 'ym_content_units_limit');
            add_shortcode('ym_bundle_units_limit', 'ym_bundle_units_limit');
            //pass ID
            add_shortcode('ym_content_expiry_date', 'ym_post_purchased_expiry');
            // so that an expiry date can be shown once a post has been purchased
            add_shortcode('ym_content_purchase_date', 'ym_post_last_purchased_date');
            //so that a purchase date can be shown once a post has been purchased
            add_shortcode('ym_bundle_expiry_date', 'ym_bundle_purchased_expiry');
            add_shortcode('ym_bundle_purchase_date', 'ym_bundle_last_purchased_date');
            // end content
            add_shortcode('ym_register', 'ym_shortcode_parse');
            add_shortcode('ym_login', 'ym_shortcode_parse');
            add_shortcode('ym_drip_date', 'ym_shortcode_parse');
            add_shortcode('ym_user_password_form', 'ym_user_password_form');
            add_shortcode('ym_user_profile_form', 'ym_user_profile_form');
            add_shortcode('ym_user_unsubscribe', 'ym_user_unsubscribe');
            add_shortcode('ym_promote', 'ym_shortcode_aff_link');
            $hook = $ym_sys->download_hook ? $ym_sys->download_hook : 'download';
            add_shortcode($hook, 'ym_dl_ins');
            //Profile Data
            add_shortcode('ym_user_register_date', 'ym_shortcode_user');
            add_shortcode('ym_user_email', 'ym_shortcode_user');
            add_shortcode('ym_user_first_name', 'ym_shortcode_user');
            add_shortcode('ym_user_last_name', 'ym_shortcode_user');
            add_shortcode('ym_user_username', 'ym_shortcode_user');
            add_shortcode('ym_user_description', 'ym_shortcode_user');
            add_shortcode('ym_user_custom', 'ym_shortcode_user');
        }
        //CSS
        add_action('wp_enqueue_scripts', 'ym_styles');
        add_action('login_enqueue_scripts', 'ym_login_styles');
        //	if ($ym_auth->ym_check_key()) {
        add_action('init', array('ym_cron', 'init'), 20);
        // run manual cron if needed, check schedules if not
        add_filter('wp_authenticate_user', 'ym_authenticate');
        if ($ym_sys->modified_registration) {
            add_action('user_register', 'ym_register', 10, 1);
            add_action('register_form', 'ym_register_form', 10, 6);
            add_action('register_post', 'ym_register_post', 10, 3);
        } else {
            add_action('user_register', 'ym_register_default', 10, 1);
        }
        /**
        WP Admin block/login redirect
        Logout redirect
        */
        add_action('login_head', 'ym_login_redirect');
        add_action('wp_login', 'ym_wp_login', 1, 2);
        add_action('admin_head', 'ym_stop_wp_admin', 1);
        add_action('wp_logout', 'ym_wp_logout', 1);
        /**
        Loginism
        */
        add_action('login_head', 'ym_login_js');
        // fire on non login page
        add_action('wp_head', 'ym_login_js');
        /**
        Login Register
        */
        // custom messages for login form
        add_filter('login_message', 'ym_login_message');
        // remove password string?
        //		add_action('login_head', 'ym_login_remove_password_string');
        /**
        Login themeing
        */
        // login page overrides
        if ($ym_sys->wp_login_header_url) {
            add_filter('login_headerurl', 'ym_login_headerurl');
            add_filter('login_headertitle', 'ym_login_headertitle');
        }
        if ($ym_sys->wp_login_header_logo) {
            add_action('login_head', 'ym_login_header_logo');
        }
        add_action('init', 'ym_subscribe_response');
        add_action('init', 'ym_upgrade_response');
        add_action('init', 'ym_register_catch_gateway');
        add_action('admin_enqueue_scripts', 'ym_admin_script_init');
        add_action('wp_head', 'ym_js_varibles');
        add_action('init', 'ym_process_response');
        add_action('parse_query', 'ym_thank_you_response');
        add_action('init', 'ym_init');
        /**
        		custom fields
        		**/
        if (is_admin()) {
            // hook for catching core fields and updating out own (wp-admin)
            add_action('profile_update', 'ym_update_custom_fields');
        }
        add_action('show_user_profile', 'ym_edit_custom_fields');
        add_action('edit_user_profile', 'ym_edit_custom_fields');
        //		add_filter('print_scripts_array', 'ym_fix_tinymce_conflict');
        add_filter('rewrite_rules_array', 'ym_rewrite_rule');
        /**
        widgets
        */
        add_action('init', 'ym_widget_init');
        add_action('init', 'ym_sidebar_init');
        add_action('init', 'ym_register_sidebar_init');
        add_filter('widget_text', 'do_shortcode');
        /**
        Email
        */
        // Replaces the From Name and Address with custom info
        if ($ym_sys->filter_all_emails) {
            add_filter('wp_mail_from', 'ym_mail_from');
            add_filter('wp_mail_from_name', 'ym_mail_from_name');
        }
        /**
        RSS Repair
        */
        add_action('atom_head', 'ym_rss_stop_payments');
        add_action('rdf_head', 'ym_rss_stop_payments');
        add_action('rss_head', 'ym_rss_stop_payments');
        add_action('rss2_head', 'ym_rss_stop_payments');
        if (is_admin()) {
            // new data export/import
            if (ym_post('ym_exporting_users')) {
                ym_export_users(ym_post('offset', 0), ym_post('limit', 300), ym_post('bkpackagetype', 'all'), ym_post('bkpackage', 'all'), ym_post('bkinactive', 0));
                exit;
            }
            ym_import_users_from_csv();
            //check for CSV import request in post
            //			add_action('after_plugin_row','ym_info_note', 10, 3);
            // only add TinyMCE buttons to Post/Page/Custom Post Type new Content/Edit Content WP Editor Field
            // if user has access to admin
            // and if the request_uri matches a known post editor location
            if (ym_admin_user_has_access(true) && strpos($_SERVER['REQUEST_URI'], 'wp-admin/post')) {
                add_action('add_meta_boxes', 'ym_meta_box_setup');
                add_action('save_post', 'ym_account_save');
                add_action('init', 'ym_tinymce_addbuttons');
            }
            // tos check
            //			ym_tos_check();
            // hooks that can result in a dialog/iframe
            add_action('admin_notices', 'ym_get_advert');
            $ym_upgrade_action = ym_check_upgrade();
            // lightbox and message hook
            if (ym_get(YM_ADMIN_FUNCTION . '_activated')) {
                add_action('admin_notices', 'ym_do_welcome_box');
                add_action('admin_notices', 'ym_activated_thanks_box');
            } else {
                if ($ym_upgrade_action) {
                    add_action('admin_notices', 'ym_do_welcome_box');
                    add_action('admin_notices', 'ym_upgrade_nag_box');
                }
            }
        }
    }
    do_action('ym_loaded_complete');
}