/** * Display navigation to next/previous set of posts when applicable. * * @since Farmtoyou 1.0 * * @global WP_Query $wp_query WordPress Query object. * @global WP_Rewrite $wp_rewrite WordPress Rewrite object. */ function farmtoyou_paging_nav() { global $wp_query, $wp_rewrite; // Don't print empty markup if there's only one page. if ($wp_query->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'farmtoyou'), 'next_text' => __('Next →', 'farmtoyou'))); if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <div class="pagination loop-pagination"> <?php echo $links; ?> </div><!-- .pagination --> </nav><!-- .navigation --> <?php } }
function abramoca_pagination($query = null) { global $wp_query; if (empty($query)) { $query = $wp_query; } if ($query->max_num_pages < 2) { return; } if (is_front_page()) { $paged = get_query_var('page') ? intval(get_query_var('page')) : 1; } else { $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; } $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'array', 'add_args' => array_map('urlencode', $query_args), 'prev_next' => True, 'prev_text' => !is_rtl() ? __('← Previous ') : __(' → Previous'), 'next_text' => !is_rtl() ? __('Next →') : __('Next ←'))); if (is_array($links)) { echo '<ul class="pagination">'; //Aquí se editaría la clase CSS de la paginación foreach ($links as $page) { echo "<li>{$page}</li>"; } echo '</ul>'; } }
function add_lang_to_link($link) { global $sitepress; $lang = ''; if (false !== ($index = strpos($link, '?'))) { // We honor the ?lang argument from the link itself (if present). $data = array(); wp_parse_str(substr($link, $index + 1), $data); if (!empty($data['lang'])) { $lang = $data['lang']; } } else { $lang = $this->get_current_language(); } if (!$lang) { return $link; } $nego_type = absint($sitepress->get_setting('language_negotiation_type')); if (1 == $nego_type) { if ($trans_id = icl_object_id(wpbdp_get_page_id(), 'page', false, $lang)) { $real_link = get_permalink($trans_id); $used_link = _get_page_link($trans_id); $link = str_replace($used_link, $real_link, $link); return $link; } } $link = add_query_arg('lang', $lang, $link); return $link; }
/** * Display navigation to next/previous set of posts when applicable. * * @since Anciela 1.0 */ function anciela_paging_nav($query = null) { // Don't print empty markup if there's only one page. if ($query == null) { $query = $GLOBALS['wp_query']; } if ($query->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Plus récents', 'anciela'), 'next_text' => __('Plus anciens →', 'anciela'))); if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <?php echo $links; ?> </nav><!-- .navigation --> <?php } }
/** * Display navigation to next/previous set of posts when applicable. * * @since hopes 1.0 */ function iva_pagination() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'iva_theme_front'), 'next_text' => __('Next →', 'iva_theme_front'))); if ($links) { $out = '<nav class="navigation paging-navigation" role="navigation">'; $out .= '<div class="pagination loop-pagination">'; $out .= $links; $out .= '</div>'; $out .= '</nav>'; } return $out; }
function gazeta_the_posts_pagination($query, $echo = true) { $pagination = ''; global $wp_query; if (empty($query)) { $query = $wp_query; } if ($query->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; $args = array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'list', 'add_args' => array_map('urlencode', $query_args), 'prev_text' => '<i class="fa fa-angle-double-left"></i>', 'next_text' => '<i class="fa fa-angle-double-right"></i>', 'before_page_number' => '<span>', 'after_page_number' => '</span>'); // Set up paginated links. $pagination = paginate_links(apply_filters('gazeta_old_navigation_args', $args)); if ($pagination) { if ($echo === false) { return '<nav class="navigation pagination"><div class="nav-links">' . $pagination . '</div></nav>'; } else { echo '<nav class="navigation pagination"><div class="nav-links">'; echo $pagination; echo '</div></nav>'; } } }
function pagination($pages = '', $range = 4) { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-angle-left"></i>', 'crunchpress'), 'next_text' => __('<i class="fa fa-angle-right"></i>', 'crunchpress'))); if ($links) { ?> <div class="pagination-all pagination" role="navigation"> <ul id='pagination'> <li> <?php echo $links; ?> </li> </ul><!-- .pagination --> </div><!-- .navigation --> <?php } }
function flat_paging_nav() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 4, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-chevron-left"></i>', 'flat'), 'next_text' => __('<i class="fa fa-chevron-right"></i>', 'flat'))); $allowed_html = array('a' => array('href' => array(), 'class' => array()), 'span' => array('class' => array()), 'i' => array('class' => array())); if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <div class="nav-links"> <?php echo wp_kses($links, $allowed_html); ?> </div> </nav> <?php } }
function _ks_parse_arg($func_get_args, $defaults = '') { $r = array(); $arg = $func_get_args[0]; if (is_object($arg)) { $r = get_object_vars($arg); if (is_array($defaults)) { $r = array_merge($defaults, $r); } } elseif (is_array($arg)) { if (is_array($defaults)) { $r = array_merge($defaults, $arg); } } elseif (is_string($arg) && count($arg) == 1 && preg_match('/^\\w+=/', $arg) && strpos($arg, ' ') === false) { // query striing wp_parse_str($arg, $r); if (is_array($defaults)) { $r = array_merge($defaults, $r); } } elseif (is_array($defaults)) { $func_get_args = (array) $func_get_args; // force array for null arguments $r = array(); foreach ($defaults as $key => $value) { $a = array_shift($func_get_args); $r[$key] = is_null($a) ? $value : $a; } } return $r; }
/** * Returns an array of photos on a WP_Error. */ private function get_photos($args = array()) { $transient_key = md5('aquick-flickr-cache-' . print_r($args, true)); $cached = get_transient($transient_key); if ($cached) { return $cached; } $username = isset($args['username']) ? $args['username'] : ''; $tags = isset($args['tags']) ? $args['tags'] : ''; $count = isset($args['count']) ? absint($args['count']) : 10; $query = array('tagmode' => 'any', 'tags' => $tags); // If username is an RSS feed if (preg_match('#^https?://api\\.flickr\\.com/services/feeds/photos_public\\.gne#', $username)) { $url = parse_url($username); $url_query = array(); wp_parse_str($url['query'], $url_query); $query = array_merge($query, $url_query); } else { $user = $this->request('flickr.people.findByUsername', array('username' => $username)); if (is_wp_error($user)) { return $user; } $user_id = $user->user->id; $query['id'] = $user_id; } $photos = $this->request_feed('photos_public', $query); if (!$photos) { return new WP_Error('error', __('Could not fetch photos.', AZ_THEME_NAME)); } $photos = array_slice($photos, 0, $count); set_transient($transient_key, $photos, apply_filters('quick_flickr_widget_cache_timeout', 3600)); return $photos; }
/** * Display navigation to next/previous set of posts when applicable. * * @return void */ function my_simone_paging_nav() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 2, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'my-simone'), 'next_text' => __('Next →', 'my-simone'), 'type' => 'list')); if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Posts navigation', 'my-simone'); ?> </h1> <?php echo $links; ?> </nav><!-- .navigation --> <?php } }
/** * Display navigation to next/previous set of posts when applicable. */ function learn_press_course_paging_nav() { if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<', 'learn_press'), 'next_text' => __('>', 'learn_press'), 'type' => 'list')); if ($links) { ?> <div class="navigation pagination"> <?php echo $links; ?> </div> <!-- .pagination --> <?php } }
function test_wp_parse_args_other() { $b = true; wp_parse_str($b, $s); $this->assertEquals($s, wp_parse_args($b)); $q = 'x=5&_baba=dudu&'; wp_parse_str($q, $ss); $this->assertEquals($ss, wp_parse_args($q)); }
/** * Catch and route requests for single activity item permalinks. * * @since 1.2.0 * * @return bool False on failure. */ function bp_activity_action_permalink_router() { // Not viewing activity. if (!bp_is_activity_component() || !bp_is_current_action('p')) { return false; } // No activity to display. if (!bp_action_variable(0) || !is_numeric(bp_action_variable(0))) { return false; } // Get the activity details. $activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(0), 'show_hidden' => true)); // 404 if activity does not exist if (empty($activity['activities'][0])) { bp_do_404(); return; } else { $activity = $activity['activities'][0]; } // Do not redirect at default. $redirect = false; // Redirect based on the type of activity. if (bp_is_active('groups') && $activity->component == buddypress()->groups->id) { // Activity is a user update. if (!empty($activity->user_id)) { $redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/'; // Activity is something else. } else { // Set redirect to group activity stream. if ($group = groups_get_group($activity->item_id)) { $redirect = bp_get_group_permalink($group) . bp_get_activity_slug() . '/' . $activity->id . '/'; } } // Set redirect to users' activity stream. } elseif (!empty($activity->user_id)) { $redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/'; } // If set, add the original query string back onto the redirect URL. if (!empty($_SERVER['QUERY_STRING'])) { $query_frags = array(); wp_parse_str($_SERVER['QUERY_STRING'], $query_frags); $redirect = add_query_arg(urlencode_deep($query_frags), $redirect); } /** * Filter the intended redirect url before the redirect occurs for the single activity item. * * @since 1.2.2 * * @param array $value Array with url to redirect to and activity related to the redirect. */ if (!($redirect = apply_filters_ref_array('bp_activity_permalink_redirect_url', array($redirect, &$activity)))) { bp_core_redirect(bp_get_root_domain()); } // Redirect to the actual activity permalink page. bp_core_redirect($redirect); }
/** * Allow $atts to be just the post_query as a string or object * * @param string|array $qs * @return array Properly formatted $atts * @since 0.4.2 */ public static function parse_query($qs) { if (is_string($qs)) { $query = array(); wp_parse_str($qs, $query); } else { $query = $qs; } return $query; }
function wp_parse_args($args, $defaults = '') { if (is_object($args)) { $r = get_object_vars($args); } elseif (is_array($args)) { $r =& $args; } else { wp_parse_str($args, $r); } return is_array($defaults) ? array_merge($defaults, $r) : $r; }
/** Ajax form handler */ function s2_ajax_form_handler() { require_once ABSPATH . '/wp-includes/shortcodes.php'; $response = str_replace(':', '&', $_POST['data']); $response = str_replace('-', '=', $response); wp_parse_str($response, $atts); global $s2_frontend; $content = $s2_frontend->shortcode($atts); $content = apply_filters('s2_ajax_form', $content); echo $content; wp_die(); }
function setup_inputs( $method = null, $url = null, $post_body = null ) { if ( is_null( $method ) ) { $this->method = strtoupper( $_SERVER['REQUEST_METHOD'] ); } else { $this->method = strtoupper( $method ); } if ( is_null( $url ) ) { $this->url = ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } else { $this->url = $url; } $parsed = parse_url( $this->url ); $this->path = $parsed['path']; if ( !empty( $parsed['query'] ) ) { wp_parse_str( $parsed['query'], $this->query ); } if ( isset( $_SERVER['HTTP_ACCEPT'] ) && $_SERVER['HTTP_ACCEPT'] ) { $this->accept = $_SERVER['HTTP_ACCEPT']; } if ( 'POST' == $this->method ) { if ( is_null( $post_body ) ) { $this->post_body = file_get_contents( 'php://input' ); if ( isset( $_SERVER['HTTP_CONTENT_TYPE'] ) && $_SERVER['HTTP_CONTENT_TYPE'] ) { $this->content_type = $_SERVER['HTTP_CONTENT_TYPE']; } elseif ( isset( $_SERVER['CONTENT_TYPE'] ) && $_SERVER['CONTENT_TYPE'] ) { $this->content_type = $_SERVER['CONTENT_TYPE'] ; } elseif ( '{' === $this->post_body[0] ) { $this->content_type = 'application/json'; } else { $this->content_type = 'application/x-www-form-urlencoded'; } if ( 0 === strpos( strtolower( $this->content_type ), 'multipart/' ) ) { $this->post_body = http_build_query( stripslashes_deep( $_POST ) ); $this->files = $_FILES; $this->content_type = 'multipart/form-data'; } } else { $this->post_body = $post_body; $this->content_type = '{' === $this->post_body[0] ? 'application/json' : 'application/x-www-form-urlencoded'; } } else { $this->post_body = null; $this->content_type = null; } $this->_server_https = array_key_exists( 'HTTPS', $_SERVER ) ? $_SERVER['HTTPS'] : '--UNset--'; }
function wp_parse_args( $args, $defaults = '' ) { if ( is_object( $args ) ) $r = get_object_vars( $args ); elseif ( is_array( $args ) ) $r =& $args; else wp_parse_str( $args, $r ); if ( is_array( $defaults ) ) return array_merge( $defaults, $r ); return $r; }
/** * Whether the current package is an MT plugin package or not. * * @param string $package The package file name or URL. * * @return bool */ protected function is_mt_package($package) { if (empty($package) || !preg_match('!^(http|https|ftp)://!i', $package) || file_exists($package)) { return false; } $query_vars = parse_url($package, PHP_URL_QUERY); if (empty($query_vars)) { return false; } wp_parse_str($query_vars, $parsed); return isset($parsed['pu_get_download']) && $parsed['pu_get_download'] == 1; }
/** * handle saving job */ public function on_save_job($job_id) { if (empty($_REQUEST['content']['raw'])) { return; } wp_parse_str($_REQUEST['content']['raw'], $args); if (empty($args['cfield'])) { return; } $fields = $args['cfield']; JEP_Field::update_job_fields($job_id, $fields); }
function update_post_order() { global $wpdb; wp_parse_str($_POST['post_order'], $data); if (is_array($data)) { foreach ($data['post'] as $position => $id) { $wpdb->update($wpdb->posts, array('menu_order' => $position), array('ID' => $id)); } } // Return result $result = array('result' => 'ok', 'data' => $data); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); }
/** * Process registration * * @since 2.1 */ public function process_signup() { global $rcp_options; $args = array('USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, 'VERSION' => '124', 'METHOD' => $this->auto_renew ? 'CreateRecurringPaymentsProfile' : 'DoDirectPayment', 'AMT' => $this->amount, 'CURRENCYCODE' => strtoupper($this->currency), 'SHIPPINGAMT' => 0, 'TAXAMT' => 0, 'DESC' => $this->subscription_name, 'SOFTDESCRIPTOR' => get_bloginfo('name') . ' - ' . $this->subscription_name, 'SOFTDESCRIPTORCITY' => get_bloginfo('admin_email'), 'CUSTOM' => $this->user_id, 'NOTIFYURL' => add_query_arg('listener', 'EIPN', home_url('index.php')), 'EMAIL' => $this->email, 'CREDITCARDTYPE' => '', 'ACCT' => sanitize_text_field($_POST['rcp_card_number']), 'EXPDATE' => sanitize_text_field($_POST['rcp_card_exp_month'] . $_POST['rcp_card_exp_year']), 'CVV2' => sanitize_text_field($_POST['rcp_card_cvc']), 'ZIP' => sanitize_text_field($_POST['rcp_card_zip']), 'BUTTONSOURCE' => 'EasyDigitalDownloads_SP', 'PROFILESTARTDATE' => date('Y-m-d\\TH:i:s', strtotime('+' . $this->length . ' ' . $this->length_unit, time())), 'BILLINGPERIOD' => ucwords($this->length_unit), 'BILLINGFREQUENCY' => $this->length, 'FAILEDINITAMTACTION' => 'CancelOnFailure', 'TOTALBILLINGCYCLES' => $this->auto_renew ? 0 : 1); if ($this->auto_renew) { $initamt = round($this->amount + $this->signup_fee, 2); if ($initamt >= 0) { $args['INITAMT'] = $initamt; } } $request = wp_remote_post($this->api_endpoint, array('timeout' => 45, 'sslverify' => false, 'httpversion' => '1.1', 'body' => $args)); $body = wp_remote_retrieve_body($request); $code = wp_remote_retrieve_response_code($request); $message = wp_remote_retrieve_response_message($request); if (is_wp_error($request)) { do_action('rcp_paypal_pro_signup_payment_failed', $request, $this); $error = '<p>' . __('An unidentified error occurred.', 'rcp') . '</p>'; $error .= '<p>' . $request->get_error_message() . '</p>'; wp_die($error, __('Error', 'rcp'), array('response' => '401')); } elseif (200 == $code && 'OK' == $message) { if (is_string($body)) { wp_parse_str($body, $body); } if (false !== strpos(strtolower($body['ACK']), 'failure')) { do_action('rcp_paypal_pro_signup_payment_failed', $request, $this); $error = '<p>' . __('PayPal subscription creation failed.', 'rcp') . '</p>'; $error .= '<p>' . __('Error message:', 'rcp') . ' ' . $body['L_LONGMESSAGE0'] . '</p>'; $error .= '<p>' . __('Error code:', 'rcp') . ' ' . $body['L_ERRORCODE0'] . '</p>'; wp_die($error, __('Error', 'rcp'), array('response' => '401')); } else { // Successful signup $member = new RCP_Member($this->user_id); if ($member->just_upgraded() && rcp_can_member_cancel($member->ID)) { $cancelled = rcp_cancel_member_payment_profile($member->ID, false); } if (isset($body['PROFILEID'])) { $member->set_payment_profile_id($body['PROFILEID']); } if (isset($body['PROFILESTATUS']) && 'ActiveProfile' === $body['PROFILESTATUS']) { // Confirm a one-time payment $member->renew($this->auto_renew); } wp_redirect(esc_url_raw(rcp_get_return_url())); exit; exit; } } else { wp_die(__('Something has gone wrong, please try again', 'rcp'), __('Error', 'rcp'), array('back_link' => true, 'response' => '401')); } }
/** * Returns the Settings page Options and total post count. * * Used by ajax action: rpbt_cache_get_cache_parameters */ function km_rpbt_cache_get_cache_settings() { global $wpdb; check_ajax_referer('rpbt_cache_nonce_ajax', 'security'); $plugin = km_rpbt_plugin(); if (!$plugin) { wp_send_json_error(__('Plugin not activated', 'rpbt-cache')); } if (!(isset($_POST['data']) && $_POST['data'])) { wp_send_json_error(__('No form data', 'rpbt-cache')); } // Parse the settings page form fields. wp_parse_str($_POST['data'], $form_data); if (!(isset($form_data['post_types']) && $form_data['post_types'])) { wp_send_json_error(__('No post types found', 'rpbt-cache')); } $batch = 50; if (isset($form_data['batch']) && absint($form_data['batch'])) { $batch = absint($form_data['batch']); } $total = -1; if (isset($form_data['total']) && $form_data['total']) { $total = (int) $form_data['total']; } $defaults = km_rpbt_get_default_args(); $data = array_merge($defaults, $form_data); $taxonomies = isset($data['taxonomies']) ? $data['taxonomies'] : $plugin->all_tax; $data['batch'] = $batch; $data['total'] = $total; $data['count'] = km_rpbtc_get_post_types_count($data['post_types']); // Settings $options_data = array_intersect_key($data, $defaults); $options_data['taxonomies'] = $taxonomies; $options_data['batch'] = $data['batch']; $options_data['total'] = $data['total']; unset($options_data['post_id']); update_option('rpbt_related_posts_cache_args', $options_data); // Create parameter list for display with Javascript. unset($options_data['count']); foreach (array('related', 'post_thumbnail') as $field) { $options_data[$field] = $options_data[$field] ? 1 : 0; } $parameters = '<h3>' . __('Cache Settings', 'rpbt-cache') . '</h3><ul>'; foreach ($options_data as $key => $value) { $parameters .= '<li>' . $key . ': ' . $value . '</li>'; } $data['parameters'] = $parameters . '</ul>'; wp_send_json_success($data); }
function flickr_embed_to_shortcode($content) { if (false === stripos($content, '/www.flickr.com/apps/video/stewart.swf')) { return $content; } $regexp = '%(<object.*?(?:<(?!/?(?:object|embed)\\s+).*?)*?)?<embed((?:\\s+\\w+="[^"]*")*)\\s+src="http(?:\\:|�*58;)//www.flickr.com/apps/video/stewart.swf[^"]*"((?:\\s+\\w+="[^"]*")*)\\s*(?:/>|>\\s*</embed>)(?(1)\\s*</object>)%'; $regexp_ent = str_replace(array('&#0*58;', '[^>]*', '[^<]*'), array('&#0*58;|�*58;', '[^&]*(?:&(?!gt;)[^&]*)*', '[^&]*(?:&(?!lt;)[^&]*)*'), htmlspecialchars($regexp, ENT_NOQUOTES)); foreach (array('regexp', 'regexp_ent') as $reg) { if (!preg_match_all(${$reg}, $content, $matches, PREG_SET_ORDER)) { continue; } foreach ($matches as $match) { $params = $match[2] . $match[3]; if ('regexp_ent' == $reg) { $params = html_entity_decode($params); } $params = wp_kses_hair($params, array('http')); if (!isset($params['type']) || 'application/x-shockwave-flash' != $params['type']['value'] || !isset($params['flashvars'])) { continue; } wp_parse_str(html_entity_decode($params['flashvars']['value']), $flashvars); if (!isset($flashvars['photo_id'])) { continue; } $code_atts = array('video' => $flashvars['photo_id']); if (isset($flashvars['flickr_show_info_box']) && 'true' == $flashvars['flickr_show_info_box']) { $code_atts['show_info'] = 'true'; } if (!empty($flashvars['photo_secret'])) { $code_atts['secret'] = $flashvars['photo_secret']; } if (!empty($params['width']['value'])) { $code_atts['w'] = (int) $params['width']['value']; } if (!empty($params['height']['value'])) { $code_atts['h'] = (int) $params['height']['value']; } $code = '[flickr'; foreach ($code_atts as $k => $v) { $code .= " {$k}={$v}"; } $code .= ']'; $content = str_replace($match[0], $code, $content); /** This action is documented in modules/shortcodes/youtube.php */ do_action('jetpack_embed_to_shortcode', 'flickr_video', $flashvars['photo_id']); } } return $content; }
/** * Adds the hook action to run users callback returning the data. */ public function do_callback() { $posted = array(); $data = maybe_serialize($_POST['data']); if (isset($data)) { wp_parse_str($data, $posted); } $this->_data_handler->set_data($posted); $this->_data_handler->add_data(array('success' => true)); // Users Callback do_action('wpajaxrequest_callback_' . $this->_action, $this->_data_handler->load_output()); if ($this->_callback === '') { echo $this->_data_handler->load_output(); } }
/** * slideshow and slideguest shortcodes for slide.com * [slideshow id=2233785415202545677&w=426&h=320] */ function jetpack_slide_embed_to_short_code($content) { global $content_width; if (false === strpos($content, 'slide.com/widgets')) { return $content; } $regexp = '!<div><embed((?:\\s+\\w+="[^"]*")*)\\s+src="http://widget[^"]+slide\\.com/widgets/slideticker\\.swf"((?:\\s+\\w+="[^"]*")*)\\s*(?:/?>|>\\s*</embed>)\\s*<div(?:\\s+[^>]+).*?slide\\.com/p1/.*?slide\\.com/p2.*?</div>\\s*</div>!i'; $regexp_ent = htmlspecialchars($regexp, ENT_NOQUOTES); foreach (array('regexp', 'regexp_ent') as $reg) { if (!preg_match_all(${$reg}, $content, $matches, PREG_SET_ORDER)) { continue; } foreach ($matches as $match) { $params = $match[1] . $match[2]; if ('regexp_ent' == $reg) { $params = html_entity_decode($params); } $params = wp_kses_hair($params, array('http')); if (!isset($params['type']) || 'application/x-shockwave-flash' != $params['type']['value'] || !isset($params['flashvars'])) { continue; } wp_parse_str(html_entity_decode($params['flashvars']['value']), $flashvars); if (empty($flashvars['channel'])) { continue; } $id = $flashvars['channel']; $width = 400; if (!empty($params['width']['value'])) { $width = (int) $params['width']['value']; } elseif (!empty($params['style']['value']) && preg_match('/width\\s*:\\s*(\\d+)/i', $params['style']['value'], $width_match)) { $width = (int) $width_match[1]; } $height = 300; if (!empty($params['height']['value'])) { $height = (int) $params['height']['value']; } elseif (!empty($params['style']['value']) && preg_match('/height\\s*:\\s*(\\d+)/i', $params['style']['value'], $height_match)) { $height = (int) $height_match[1]; } if ($content_width && $width > $content_width) { $height = intval($height * $content_width / $width); $width = $content_width; } $content = str_replace($match[0], "[slideshow id={$id}&w={$width}&h={$height}]", $content); do_action('jetpack_embed_to_shortcode', 'slideshow', $id); } } return $content; }
public function get_current_action($default = null) { $blacklist = $this->params_blacklist(); // return current bulk-action, if one was selected if (!$this->action) { $this->action = $this->get_table()->current_action(); } if (!$this->action) { $this->action = awpcp_request_param('action', 'index'); } if (!isset($this->params) || empty($this->params)) { wp_parse_str($_SERVER['QUERY_STRING'], $_params); $this->params = array_diff_key($_params, array_combine($blacklist, $blacklist)); } return $this->action; }
/** * Display navigation to next/previous set of posts when applicable. */ function bpxl_paging_nav() { global $bpxl_goblog_options; // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'bloompixel'), 'next_text' => __('Next →', 'bloompixel'))); if ($bpxl_goblog_options['bpxl_pagination_type'] == '1') { if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <div class="pagination loop-pagination"> <?php echo $links; ?> </div><!-- .pagination --> </nav><!-- .navigation --> <?php } } else { ?> <nav class="norm-pagination" role="navigation"> <div class="nav-previous"><?php next_posts_link('← ' . __('Older posts', 'bloompixel')); ?> </div> <div class="nav-next"><?php previous_posts_link(__('Newer posts', 'bloompixel') . ' →'); ?> </div> </nav> <?php } }
/** * Display navigation to next/previous pages when applicable * * To be honest - I'm pretty proud of this function. Through a lot of trial and * error, I was able to user a core WordPress function (paginate_links()) and * adjust it in a way, that the end result is a legitimate pagination. * A pagination many developers buy (code) expensively with Plugins like * WP Pagenavi. No need! WordPress has it all! * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_content_nav() { global $wp_query, $wp_rewrite; $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = ($wp_rewrite->using_index_permalinks() and !strpos($pagenum_link, 'index.php')) ? 'index.php/' : ''; $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'list', 'add_args' => array_map('urlencode', $query_args))); if ($links) { echo "<nav class=\"pagination pagination-centered clearfix\">{$links}</nav>"; } }