public static function shortcode($attr = array(), $content = "", $shortcode = "") { return c_ws_plugin__s2member_pro_sc_mop_vars_notice_in::shortcode($attr, $content, $shortcode); }
public static function shortcode($attr = array(), $content = '', $shortcode = '') { $_g = stripslashes_deep($_GET); // Cleanup the query string vars. if (!isset($_g['_s2member_seeking']) || !is_array($_g['_s2member_seeking']) || empty($_SERVER['QUERY_STRING']) || !c_ws_plugin__s2member_utils_urls::s2member_sig_ok($_SERVER['QUERY_STRING'])) { return ''; } $valid_required_types = array('level', 'ccap', 'sp'); $valid_seeking_types = array('page', 'post', 'catg', 'ptag', 'file', 'ruri'); $valid_restriction_types = array('page', 'post', 'catg', 'ptag', 'file', 'ruri', 'ccap', 'sp', 'sys'); $attr = shortcode_atts(array('seeking_type' => '', 'required_type' => '', 'required_value' => '', 'restriction_type' => ''), $attr, $shortcode); # --------------------------------------------------------------------------------------------------- if ($attr['seeking_type'] !== '' || $attr['required_type'] !== '' || $attr['restriction_type'] !== '') { $attr['seeking_type'] = array_unique(preg_split('/[|;,\\s]+/', $attr['seeking_type'], NULL, PREG_SPLIT_NO_EMPTY)); $attr['required_type'] = array_unique(preg_split('/[|;,\\s]+/', $attr['required_type'], NULL, PREG_SPLIT_NO_EMPTY)); $attr['required_value'] = array_unique(preg_split('/[|;,\\s]+/', $attr['required_value'], NULL, PREG_SPLIT_NO_EMPTY)); $attr['restriction_type'] = array_unique(preg_split('/[|;,\\s]+/', $attr['restriction_type'], NULL, PREG_SPLIT_NO_EMPTY)); if (array_intersect($attr['seeking_type'], $valid_seeking_types)) { if (empty($_g['_s2member_seeking']['type']) || !in_array($_g['_s2member_seeking']['type'], $attr['seeking_type'], TRUE)) { return ''; } } if (array_intersect($attr['required_type'], $valid_required_types)) { if (empty($_g['_s2member_req']['type']) || !in_array($_g['_s2member_req']['type'], $attr['required_type'], TRUE)) { return ''; } $required_type = $_g['_s2member_req']['type']; if (!empty($attr['required_value']) && (count($attr['required_type']) !== 1 || !in_array($_g['_s2member_req'][$required_type], $attr['required_value'], TRUE))) { return ''; } } if (array_intersect($attr['restriction_type'], $valid_restriction_types)) { if (empty($_g['_s2member_res']['type']) || !in_array($_g['_s2member_res']['type'], $attr['restriction_type'], TRUE)) { return ''; } } } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_seeking']['type'])) { $seeking_type_tag = ''; // Initialize. // Let's give the replacement tags a name that's useful for building messages switch (strtolower($_g['_s2member_seeking']['type'])) { case 'page': $seeking_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_seeking_type_page', 'Page', get_defined_vars()); break; case 'post': $seeking_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_seeking_type_post', 'Post', get_defined_vars()); break; case 'catg': $seeking_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_seeking_type_catg', 'Category', get_defined_vars()); break; case 'ptag': $seeking_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_seeking_type_ptag', 'Tag', get_defined_vars()); break; case 'file': $seeking_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_seeking_type_file', 'File', get_defined_vars()); break; case 'ruri': $seeking_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_seeking_type_ruri', 'URI', get_defined_vars()); break; } $content = str_ireplace('%%SEEKING_TYPE%%', esc_html($seeking_type_tag), $content); } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_seeking']['page'])) { $content = str_ireplace('%%SEEKING_PAGE_ID%%', esc_html($_g['_s2member_seeking']['page']), $content); } else { if (!empty($_g['_s2member_seeking']['post'])) { $content = str_ireplace('%%SEEKING_POST_ID%%', esc_html($_g['_s2member_seeking']['post']), $content); } else { if (!empty($_g['_s2member_seeking']['catg'])) { $content = str_ireplace('%%SEEKING_CAT_ID%%', esc_html($_g['_s2member_seeking']['catg']), $content); } else { if (!empty($_g['_s2member_seeking']['ptag'])) { $content = str_ireplace('%%SEEKING_TAG_ID%%', esc_html($_g['_s2member_seeking']['ptag']), $content); } else { if (!empty($_g['_s2member_seeking']['file'])) { $content = str_ireplace('%%SEEKING_FILE%%', esc_html($_g['_s2member_seeking']['file']), $content); } else { if (!empty($_g['_s2member_seeking']['ruri'])) { $content = str_ireplace('%%SEEKING_RURI%%', esc_html(base64_decode($_g['_s2member_seeking']['ruri'])), $content); } } } } } } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_seeking']['_uri'])) { $content = str_ireplace('%%SEEKING_URI%%', esc_html(home_url(base64_decode($_g['_s2member_seeking']['_uri']))), $content); } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_req']['type'])) { $required_type_tag = ''; // Initialize. // Let's give the replacement tags a name that's useful for building messages switch (strtolower($_g['_s2member_req']['type'])) { case 'level': $required_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_required_type_level', 'Level', get_defined_vars()); break; case 'ccap': $required_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_required_type_ccap', 'Capability', get_defined_vars()); break; case 'sp': $required_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_required_type_sp', 'Specific Post/Page', get_defined_vars()); break; } $content = str_ireplace('%%REQUIRED_TYPE%%', esc_html($required_type_tag), $content); } # --------------------------------------------------------------------------------------------------- if (isset($_g['_s2member_req']['level'])) { $content = str_ireplace('%%REQUIRED_LEVEL%%', esc_html($_g['_s2member_req']['level']), $content); if (!empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $_g['_s2member_req']['level'] . '_label'])) { $content = str_ireplace('%%REQUIRED_LEVEL_LABEL%%', esc_html($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $_g['_s2member_req']['level'] . '_label']), $content); } } else { if (!empty($_g['_s2member_req']['ccap'])) { $content = str_ireplace('%%REQUIRED_CCAP%%', esc_html($_g['_s2member_req']['ccap']), $content); } else { if (!empty($_g['_s2member_req']['sp'])) { $content = str_ireplace('%%REQUIRED_SP%%', esc_html($_g['_s2member_req']['sp']), $content); } } } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_res']['type'])) { $restriction_type_tag = ''; // Initialize. // Let's give the replacement tags a name that's useful for building messages switch (strtolower($_g['_s2member_seeking']['type'])) { case 'page': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_page', 'Page', get_defined_vars()); break; case 'post': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_post', 'Post', get_defined_vars()); break; case 'catg': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_catg', 'Category', get_defined_vars()); break; case 'ptag': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_ptag', 'Tag', get_defined_vars()); break; case 'file': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_file', 'File', get_defined_vars()); break; case 'ruri': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_ruri', 'URI', get_defined_vars()); break; case 'ccap': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_ccap', 'Custom Capability', get_defined_vars()); break; case 'sp': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_sp', 'Specific Post/Page', get_defined_vars()); break; case 'sys': $restriction_type_tag = apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_restriction_type_sys', 'Systematic', get_defined_vars()); break; } $content = str_ireplace('%%RESTRICTION_TYPE%%', esc_html($restriction_type_tag), $content); } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_seeking']['type']) && $_g['_s2member_seeking']['type'] == 'post') { $content = str_ireplace(array('%%POST_TITLE%%', '%%PAGE_TITLE%%'), get_the_title((int) $_g['_s2member_seeking']['post']), $content); $content = str_ireplace('%%POST_EXCERPT%%', c_ws_plugin__s2member_pro_sc_mop_vars_notice_in::get_excerpt((int) $_g['_s2member_seeking']['post']), $content); } # --------------------------------------------------------------------------------------------------- if (!empty($_g['_s2member_seeking']['type']) && $_g['_s2member_seeking']['type'] == 'page') { $content = str_ireplace(array('%%POST_TITLE%%', '%%PAGE_TITLE%%'), get_the_title((int) $_g['_s2member_seeking']['page']), $content); } # --------------------------------------------------------------------------------------------------- return apply_filters('c_ws_plugin__s2member_pro_sc_mop_vars_notice_content', do_shortcode($content), get_defined_vars()); }