コード例 #1
1
 /**
  * Prepare the PayPal IPN fields
  *
  * Details here:
  * https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
  *
  * @since  1.0.0
  * @return array
  */
 private function prepare_fields()
 {
     $subscription = $this->data['ms_relationship'];
     $membership = $subscription->get_membership();
     if (0 === $membership->price) {
         return;
     }
     $gateway = $this->data['gateway'];
     $invoice = $subscription->get_current_invoice();
     $fields = array('business' => array('id' => 'business', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->paypal_email), 'cmd' => array('id' => 'cmd', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => '_xclick'), 'bn' => array('id' => 'bn', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 'incsub_SP'), 'item_number' => array('id' => 'item_number', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $subscription->membership_id), 'item_name' => array('id' => 'item_name', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->name), 'amount' => array('id' => 'amount', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Helper_Billing::format_price($invoice->total)), 'currency_code' => array('id' => 'currency_code', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->currency), 'return' => array('id' => 'return', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => esc_url_raw(add_query_arg(array('ms_relationship_id' => $subscription->id), MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE, false)))), 'cancel_return' => array('id' => 'cancel_return', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER)), 'notify_url' => array('id' => 'notify_url', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->get_return_url()), 'lc' => array('id' => 'lc', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->paypal_site), 'invoice' => array('id' => 'invoice', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id));
     // Don't send to paypal if free
     if (0 === $invoice->total) {
         $fields = array('gateway' => array('id' => 'gateway', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->id), 'ms_relationship_id' => array('id' => 'ms_relationship_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $subscription->id), 'step' => array('id' => 'step', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Controller_Frontend::STEP_PROCESS_PURCHASE), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($gateway->id . '_' . $subscription->id)));
         $this->data['action_url'] = null;
     } else {
         if ($gateway->is_live_mode()) {
             $this->data['action_url'] = 'https://www.paypal.com/cgi-bin/webscr';
         } else {
             $this->data['action_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
         }
     }
     $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_IMAGE, 'value' => 'https://www.paypalobjects.com/en_US/i/btn/x-click-but06.gif', 'alt' => __('PayPal - The safer, easier way to pay online', MS_TEXT_DOMAIN));
     // custom pay button defined in gateway settings
     $custom_label = $gateway->pay_button_url;
     if (!empty($custom_label)) {
         if (false !== strpos($custom_label, '://')) {
             $fields['submit']['value'] = $custom_label;
         } else {
             $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => $custom_label);
         }
     }
     return apply_filters('ms_gateway_paypalsingle_view_prepare_fields', $fields);
 }
コード例 #2
0
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $fields = $this->prepare_fields();
        $form_url = esc_url_raw(remove_query_arg(array('action', 'invitation_id')));
        if ($this->data['invitation']->is_valid()) {
            $title = __('Edit Invitation Code', MS_TEXT_DOMAIN);
        } else {
            $title = __('Add Invitation Code', MS_TEXT_DOMAIN);
        }
        ob_start();
        ?>
		<div class="ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-pencil-square'));
        ?>
			<form action="<?php 
        echo esc_url($form_url);
        ?>
" method="post" class="ms-form">
				<?php 
        MS_Helper_Html::settings_box($fields, '', '', 'static', 'ms-small-form');
        ?>
			</form>
			<div class="clear"></div>
		</div>
		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_addon_invitation_view_edit_to_html', $html, $this);
    }
コード例 #3
0
 public static function init_hooks()
 {
     // The standalone stats page was removed in 3.0 for an all-in-one config and stats page.
     // Redirect any links that might have been bookmarked or in browser history.
     if (isset($_GET['page']) && 'akismet-stats-display' == $_GET['page']) {
         wp_safe_redirect(esc_url_raw(self::get_page_url('stats')), 301);
         die;
     }
     self::$initiated = true;
     add_action('admin_init', array('Akismet_Admin', 'admin_init'));
     add_action('admin_menu', array('Akismet_Admin', 'admin_menu'), 5);
     # Priority 5, so it's called before Jetpack's admin_menu.
     add_action('admin_notices', array('Akismet_Admin', 'display_notice'));
     add_action('admin_enqueue_scripts', array('Akismet_Admin', 'load_resources'));
     add_action('activity_box_end', array('Akismet_Admin', 'dashboard_stats'));
     add_action('rightnow_end', array('Akismet_Admin', 'rightnow_stats'));
     add_action('manage_comments_nav', array('Akismet_Admin', 'check_for_spam_button'));
     add_action('transition_comment_status', array('Akismet_Admin', 'transition_comment_status'), 10, 3);
     add_action('admin_action_akismet_recheck_queue', array('Akismet_Admin', 'recheck_queue'));
     add_action('wp_ajax_akismet_recheck_queue', array('Akismet_Admin', 'recheck_queue'));
     add_action('wp_ajax_comment_author_deurl', array('Akismet_Admin', 'remove_comment_author_url'));
     add_action('wp_ajax_comment_author_reurl', array('Akismet_Admin', 'add_comment_author_url'));
     add_filter('plugin_action_links', array('Akismet_Admin', 'plugin_action_links'), 10, 2);
     add_filter('comment_row_actions', array('Akismet_Admin', 'comment_row_action'), 10, 2);
     add_filter('comment_text', array('Akismet_Admin', 'text_add_link_class'));
     add_filter('plugin_action_links_' . plugin_basename(plugin_dir_path(__FILE__) . 'akismet.php'), array('Akismet_Admin', 'admin_plugin_settings_link'));
 }
コード例 #4
0
 public function new_service($label, $url, $icon)
 {
     // Validate
     $label = trim(wp_html_excerpt(wp_kses($label, array()), 30));
     $url = trim(esc_url_raw($url));
     $icon = trim(esc_url_raw($icon));
     if ($label && $url && $icon) {
         $options = get_option('sharing-options');
         if (!is_array($options)) {
             $options = array();
         }
         $service_id = 'custom-' . time();
         // Add a new custom service
         $options['global']['custom'][] = $service_id;
         if (false !== $this->global) {
             $this->global['custom'][] = $service_id;
         }
         update_option('sharing-options', $options);
         // Create a custom service and set the options for it
         $service = new Share_Custom($service_id, array('name' => $label, 'url' => $url, 'icon' => $icon));
         $this->set_service($service_id, $service);
         // Return the service
         return $service;
     }
     return false;
 }
コード例 #5
0
 public static function reversal($content)
 {
     if (false === stripos($content, '<script') && false === stripos($content, '<iframe') && false === stripos($content, 'class="instagram-media')) {
         return $content;
     }
     $needle = '#<blockquote class="instagram-media.+<a href="(https://instagram\\.com/p/[^/]+/)"[^>]+>.+(?=</blockquote>)</blockquote>\\n?(<script[^>]+src="//platform\\.instagram\\.com/[^>]+></script>)?#';
     if (preg_match_all($needle, $content, $matches)) {
         $replacements = array();
         $shortcode_tag = self::get_shortcode_tag();
         foreach ($matches[0] as $key => $value) {
             $replacements[$value] = '[' . $shortcode_tag . ' url="' . esc_url_raw($matches[1][$key]) . '"]';
         }
         $content = self::make_replacements_to_content($content, $replacements);
     }
     if ($iframes = self::parse_iframes($content)) {
         $replacements = array();
         foreach ($iframes as $iframe) {
             if ('instagram.com' !== self::parse_url($iframe->attrs['src'], PHP_URL_HOST)) {
                 continue;
             }
             if (preg_match('#//instagram\\.com/p/([^/]+)/embed/?#', $iframe->attrs['src'], $matches)) {
                 $embed_id = $matches[1];
             } else {
                 continue;
             }
             $replacements[$iframe->original] = '[' . self::get_shortcode_tag() . ' url="' . esc_url_raw('https://instagram.com/p/' . $embed_id . '/') . '"]';
         }
         $content = self::make_replacements_to_content($content, $replacements);
     }
     return $content;
 }
 private function prepare_fields()
 {
     $gateway = $this->data['gateway'];
     $subscription = $this->data['ms_relationship'];
     $membership = $subscription->get_membership();
     $invoice = $subscription->get_current_invoice();
     $member = $subscription->get_member();
     $fields = array('sid' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'sid', 'value' => $gateway->seller_id), 'mode' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'mode', 'value' => '2CO'), 'type' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'li_0_type', 'value' => 'product'), 'name' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'li_0_name', 'value' => $membership->name), 'price' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'li_0_price', 'value' => $invoice->total), 'tangible' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'li_0_tangible', 'value' => 'N'), 'skip_landing' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'skip_landing', 'value' => '1'), 'user_id' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'user_id', 'value' => $member->id), 'email' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'email', 'value' => $member->email), 'currency' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'currency', 'value' => $invoice->currency), 'merchant_order_id' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'merchant_order_id', 'value' => $invoice->id), 'return_url' => array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'id' => 'x_receipt_link_url', 'value' => esc_url_raw(add_query_arg(array('ms_relationship_id' => $subscription->id), MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE, false)))));
     if (MS_Model_Membership::PAYMENT_TYPE_RECURRING == $membership->payment_type) {
         #'li_0_reccurance' = '2 days'   // Can use # Week / # Month / # Year
         #'li_0_duration' = 'Forever'    // Same as _recurrence, with additional "Forever" option
     }
     if (false !== strpos($gateway->pay_button_url, '://')) {
         $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_IMAGE, 'value' => $gateway->pay_button_url);
     } else {
         $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Signup', MS_TEXT_DOMAIN));
         if ($gateway->pay_button_url) {
             $fields['submit']['value'] = $gateway->pay_button_url;
         }
     }
     // Don't send to gateway if free
     if (0 === $invoice->total) {
         $this->data['action_url'] = null;
     } else {
         if ($gateway->is_live_mode()) {
             $this->data['action_url'] = 'https://www.2checkout.com/checkout/purchase';
         } else {
             $this->data['action_url'] = 'https://sandbox.2checkout.com/checkout/purchase';
         }
     }
     return $fields;
 }
コード例 #7
0
function jetpack_instagram_handler($matches, $atts, $url)
{
    global $content_width;
    static $did_script;
    // keep a copy of the passed-in URL since it's modified below
    $passed_url = $url;
    $max_width = 698;
    $min_width = 320;
    if (is_feed()) {
        $media_url = sprintf('http://instagr.am/p/%s/media/?size=l', $matches[2]);
        return sprintf('<a href="%s" title="%s"><img src="%s" alt="Instagram Photo" /></a>', esc_url($url), esc_attr__('View on Instagram', 'jetpack'), esc_url($media_url));
    }
    $atts = shortcode_atts(array('width' => isset($content_width) ? $content_width : $max_width, 'hidecaption' => false), $atts);
    $atts['width'] = absint($atts['width']);
    if ($atts['width'] > $max_width || $min_width > $atts['width']) {
        $atts['width'] = $max_width;
    }
    // remove the modal param from the URL
    $url = remove_query_arg('modal', $url);
    // force .com instead of .am for https support
    $url = str_replace('instagr.am', 'instagram.com', $url);
    // The oembed endpoint expects HTTP, but HTTP requests 301 to HTTPS
    $instagram_http_url = str_replace('https://', 'http://', $url);
    $instagram_https_url = str_replace('http://', 'https://', $url);
    $url_args = array('url' => $instagram_http_url, 'maxwidth' => $atts['width']);
    if ($atts['hidecaption']) {
        $url_args['hidecaption'] = 'true';
    }
    $url = esc_url_raw(add_query_arg($url_args, 'https://api.instagram.com/oembed/'));
    // Don't use object caching here by default, but give themes ability to turn it on.
    $response_body_use_cache = apply_filters('instagram_cache_oembed_api_response_body', false, $matches, $atts, $passed_url);
    $response_body = false;
    if ($response_body_use_cache) {
        $cache_key = 'oembed_response_body_' . md5($url);
        $response_body = wp_cache_get($cache_key, 'instagram_embeds');
    }
    if (!$response_body) {
        // Not using cache (default case) or cache miss
        $instagram_response = wp_remote_get($url, array('redirection' => 0));
        if (is_wp_error($instagram_response) || 200 != $instagram_response['response']['code'] || empty($instagram_response['body'])) {
            return "<!-- instagram error: invalid oratv resource -->";
        }
        $response_body = json_decode($instagram_response['body']);
        if ($response_body_use_cache) {
            // if caching it is short-lived since this is a "Cache-Control: no-cache" resource
            wp_cache_set($cache_key, $response_body, 'instagram_embeds', HOUR_IN_SECONDS + mt_rand(0, HOUR_IN_SECONDS));
        }
    }
    if (!empty($response_body->html)) {
        if (!$did_script) {
            $did_script = true;
            add_action('wp_footer', 'jetpack_instagram_add_script');
        }
        // there's a script in the response, which we strip on purpose since it's added above
        $ig_embed = preg_replace('@<(script)[^>]*?>.*?</\\1>@si', '', $response_body->html);
    } else {
        $ig_embed = jetpack_instagram_iframe_embed($instagram_https_url, $atts);
    }
    return $ig_embed;
}
コード例 #8
0
ファイル: functions.php プロジェクト: keplerf/Partybuses.ca
/**
 * Return the URL for the first link found in the post content.
 *
 * @since Twenty Eleven 1.0
 * @return string|bool URL or false when no link is present.
 */
function twentyeleven_url_grabber()
{
    if (!preg_match('/<a\\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches)) {
        return false;
    }
    return esc_url_raw($matches[1]);
}
コード例 #9
0
ファイル: filters.php プロジェクト: gvh1993/project-vvvh
/**
 * Redirects user after logout
 */
function palo_filter_logout_redirect($is_admin = false)
{
    global $palo_options;
    if ($is_admin || empty($palo_options['palo_logout_behavior'])) {
        $palo_logout_behavior = 'PALO_REDIRECT_DEFAULT';
    } else {
        $palo_logout_behavior = $palo_options['palo_logout_behavior'];
    }
    $referer = array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : '';
    /**
     * Perform the redirect
     */
    switch ($palo_logout_behavior) {
        case 'PALO_REDIRECT_HOME':
            wp_redirect(home_url());
            exit;
        case 'PALO_REDIRECT_URL':
            wp_redirect(esc_url_raw($palo_options['palo_logout_url']));
            exit;
        case 'PALO_REDIRECT_CURRENT':
            if ($referer) {
                wp_redirect(esc_url_raw($referer));
            } else {
                wp_redirect(home_url());
            }
            exit;
        default:
            wp_redirect(wp_login_url());
            /* Nothing */
    }
}
コード例 #10
0
 function form_html()
 {
     $form = '<div class="wpcf7" id="' . $this->unit_tag . '">';
     $url = wpcf7_get_request_uri();
     if ($frag = strstr($url, '#')) {
         $url = substr($url, 0, -strlen($frag));
     }
     $url .= '#' . $this->unit_tag;
     $url = apply_filters('wpcf7_form_action_url', $url);
     $enctype = apply_filters('wpcf7_form_enctype', '');
     $class = apply_filters('wpcf7_form_class_attr', 'wpcf7-form');
     $form .= '<form action="' . esc_url_raw($url) . '" method="post"' . ' class="' . esc_attr($class) . '"' . $enctype . '>' . "\n";
     $form .= '<div style="display: none;">' . "\n";
     $form .= '<input type="hidden" name="_wpcf7" value="' . esc_attr($this->id) . '" />' . "\n";
     $form .= '<input type="hidden" name="_wpcf7_version" value="' . esc_attr(WPCF7_VERSION) . '" />' . "\n";
     $form .= '<input type="hidden" name="_wpcf7_unit_tag" value="' . esc_attr($this->unit_tag) . '" />' . "\n";
     $form .= '</div>' . "\n";
     $form .= $this->form_elements();
     if (!$this->responses_count) {
         $form .= $this->form_response_output();
     }
     $form .= '</form>';
     $form .= '</div>';
     return $form;
 }
コード例 #11
0
 static function pranon_video_link_save($post_id)
 {
     // Check if our nonce is set.
     if (!isset($_POST['pranon_meta_box_video_nonce'])) {
         return;
     }
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($_POST['pranon_meta_box_video_nonce'], 'pranon_meta_box_video')) {
         return;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Check the user's permissions.
     if (isset($_POST['post_type'])) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     /* OK, it's safe for us to save the data now. */
     // Make sure that it is set.
     if (!isset($_POST['pranon_video_url'])) {
         return;
     }
     // Sanitize user input.
     $my_data = esc_url_raw($_POST['pranon_video_url']);
     // Update the meta field in the database.
     update_post_meta($post_id, 'pranon_video_url', $my_data);
 }
コード例 #12
0
 /**
  * Save post custom fields
  *
  * This function is attached to the 'pre_post_update' action hook.
  *
  * @since 1.0.0
  */
 public function pre_post_update($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Check if quick edit
     if (!empty($_POST['_inline_edit']) && wp_verify_nonce($_POST['_inline_edit'], 'inlineeditnonce')) {
         return;
     }
     if (!empty($_POST['arcade_basic_nonce']) && !wp_verify_nonce($_POST['arcade_basic_nonce'], 'arcade_basic_nonce')) {
         return;
     }
     if (!empty($_POST['post_type']) && 'page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     // Sanitize
     $arcade_basic_custom_image = isset($_POST['arcade_basic_custom_image']) ? esc_url_raw($_POST['arcade_basic_custom_image']) : '';
     $this->save_meta_value($post_id, 'arcade_basic_custom_image', $arcade_basic_custom_image);
 }
コード例 #13
0
 /**
  * Uses the Brightcove oAuth API to retrieve and store an access key for use with requests. The token is stored as a transient
  * with an expiration time matching that which is returned from Brightcove. The call to the API is only performed if that transient
  * is invalid or expired. Return a WP_Error object for use in WordPress in the case of failure.
  *
  * @since  1.0.0
  *
  * @see    get_transient()
  * @see    set_transient()
  * @see    delete_transient()
  * @see    wp_remote_post()
  *
  * @param bool $force_new_token whether or not to obtain a new OAuth token
  * @param bool $retry           true to retry on failure or false
  *
  * @return string|WP_Error
  */
 public function _request_access_token($force_new_token = false, $retry = true)
 {
     $transient_name = $this->transient_name;
     $token = $force_new_token ? false : get_transient($transient_name);
     if (!$token) {
         $endpoint = esc_url_raw(self::ENDPOINT_BASE . '/access_token?grant_type=client_credentials');
         $request = wp_remote_post($endpoint, $this->_http_headers);
         if ('400' == wp_remote_retrieve_response_code($request)) {
             // Just in case
             delete_transient($transient_name);
             $oauth_error = new WP_Error('oauth_access_token_failure', sprintf(__('There is a problem with your Brightcove %1$s or %2$s', 'brightcove'), '<code>client_id</code>', '<code>client_secret</code>'));
             BC_Logging::log(sprintf('BC OAUTH ERROR: %s', $oauth_error->get_error_message()));
             return $oauth_error;
         }
         $body = wp_remote_retrieve_body($request);
         $data = json_decode($body);
         if (isset($data->access_token)) {
             $token = $data->access_token;
             set_transient($transient_name, $token, $data->expires_in);
         } else {
             if (!$retry) {
                 return new WP_Error('oauth_access_token_response_failure', sprintf(esc_html__('oAuth API did not return us an access token', 'brightcove')));
             }
             return $this->_request_access_token($force_new_token, false);
         }
     }
     return $token;
 }
コード例 #14
0
/**
 * Loads our special font CSS file.
 *
 * @since Twenty Twelve 1.2
 *
 * @return void
 */
function cafemocha_custom_header_fonts()
{
    $font_url = cafemocha_get_font_url();
    if (!empty($font_url)) {
        wp_enqueue_style('cafemocha-fonts', esc_url_raw($font_url), array(), null);
    }
}
コード例 #15
0
 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @since 4.4.0
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     $url = esc_url_raw(get_query_var('url'));
     $format = wp_oembed_ensure_format(get_query_var('format'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @since 4.4.0
      *
      * @param int $maxwidth Maximum allowed width. Default 600.
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = absint(get_query_var('maxwidth', $maxwidth));
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
コード例 #16
0
ファイル: sponsors.php プロジェクト: GaryJones/sbcg
function _sbcg_sponsors_meta_save($post_id)
{
    // Check if our nonce is set.
    if (!isset($_POST['_sbcg_sponsors_website_nonce'])) {
        return;
    }
    // Verify that the nonce is valid.
    if (!wp_verify_nonce($_POST['_sbcg_sponsors_website_nonce'], '_sbcg_sponsors_website')) {
        return;
    }
    // Don't save on autosave.
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // Check the user's permissions.
    if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    // Make sure that it is set.
    if (!isset($_POST['_sbcg_sponsors_website'])) {
        return;
    }
    // Sanitize user input.
    $my_data = esc_url_raw($_POST['_sbcg_sponsors_website']);
    // Update the meta field in the database.
    update_post_meta($post_id, '_sbcg_sponsors_value_key', $my_data);
}
コード例 #17
0
 function __construct()
 {
     global $wpdb;
     $this->bmp_table = $wpdb->base_prefix . 'rt_rtm_media';
     add_action('admin_menu', array($this, 'menu'));
     add_action('wp_ajax_bp_media_rt_db_migration', array($this, 'migrate_to_new_db'));
     if (isset($_REQUEST['page']) && 'rtmedia-migration' == $_REQUEST['page'] && isset($_REQUEST['hide']) && 'true' == $_REQUEST['hide']) {
         $this->hide_migration_notice();
         wp_safe_redirect(esc_url_raw($_SERVER['HTTP_REFERER']));
     }
     if (false !== rtmedia_get_site_option('rt_migration_hide_notice')) {
         return true;
     }
     if (isset($_REQUEST['force']) && 'true' === $_REQUEST['force']) {
         $pending = false;
     } else {
         $pending = rtmedia_get_site_option('rtMigration-pending-count');
     }
     if (false === $pending) {
         $total = $this->get_total_count();
         $done = $this->get_done_count();
         $pending = $total - $done;
         if ($pending < 0) {
             $pending = 0;
         }
         rtmedia_update_site_option('rtMigration-pending-count', $pending);
     }
     if ($pending > 0) {
         if (!(isset($_REQUEST['page']) && 'rtmedia-migration' == $_REQUEST['page'])) {
             add_action('admin_notices', array(&$this, 'add_migration_notice'));
         }
     }
 }
コード例 #18
0
ファイル: class-kirki-init.php プロジェクト: aristath/kirki
 /**
  * Properly set the Kirki URL for assets.
  * Determines if Kirki is installed as a plugin, in a child theme, or a parent theme
  * and then does some calculations to get the proper URL for its CSS & JS assets.
  */
 public function set_url()
 {
     // The path of the Kirki's parent-folder.
     $path = wp_normalize_path(dirname(Kirki::$path));
     // Get parent-theme path.
     $parent_theme_path = get_template_directory();
     $parent_theme_path = wp_normalize_path($parent_theme_path);
     // Get child-theme path.
     $child_theme_path = get_stylesheet_directory_uri();
     $child_theme_path = wp_normalize_path($child_theme_path);
     Kirki::$url = plugin_dir_url(dirname(__FILE__) . 'kirki.php');
     // Is Kirki included in a parent theme?
     if (false !== strpos(Kirki::$path, $parent_theme_path)) {
         Kirki::$url = get_template_directory_uri() . str_replace($parent_theme_path, '', Kirki::$path);
     }
     // Is there a child-theme?
     if ($child_theme_path !== $parent_theme_path) {
         // Is Kirki included in a child theme?
         if (false !== strpos(Kirki::$path, $child_theme_path)) {
             Kirki::$url = get_template_directory_uri() . str_replace($child_theme_path, '', Kirki::$path);
         }
     }
     // Apply the kirki/config filter.
     $config = apply_filters('kirki/config', array());
     if (isset($config['url_path'])) {
         Kirki::$url = esc_url_raw($config['url_path']);
     }
 }
コード例 #19
0
 /**
  * Generate a URL to an endpoint
  *
  * Used to construct meta links in API responses
  *
  * @param mixed $args Optional arguments to be appended to URL
  * @return string Endpoint URL
  **/
 function get_link()
 {
     $args = func_get_args();
     $format = array_shift($args);
     $base = WPCOM_JSON_API__BASE;
     $path = array_pop($args);
     if ($path) {
         $path = '/' . ltrim($path, '/');
     }
     $args[] = $path;
     // Escape any % in args before using sprintf
     $escaped_args = array();
     foreach ($args as $arg_key => $arg_value) {
         $escaped_args[$arg_key] = str_replace('%', '%%', $arg_value);
     }
     $relative_path = vsprintf("{$format}%s", $escaped_args);
     if (!wp_startswith($relative_path, '.')) {
         // Generic version. Match the requested version as best we can
         $api_version = $this->get_closest_version_of_endpoint($format, $relative_path);
         $base = substr($base, 0, -1) . $api_version;
     }
     // escape any % in the relative path before running it through sprintf again
     $relative_path = str_replace('%', '%%', $relative_path);
     // http, WPCOM_JSON_API__BASE, ...    , path
     // %s  , %s                  , $format, %s
     return esc_url_raw(sprintf("https://%s{$relative_path}", $base));
 }
コード例 #20
0
ファイル: shipping.php プロジェクト: ashik968/digiplot
 public function callback_submit_options()
 {
     global $wpsc_shipping_modules;
     foreach ($wpsc_shipping_modules as $shipping) {
         if (is_object($shipping)) {
             $shipping->submit_form();
         }
     }
     //This is for submitting shipping details to the shipping module
     if (!isset($_POST['update_gateways'])) {
         $_POST['update_gateways'] = '';
     }
     if (!isset($_POST['custom_shipping_options'])) {
         $_POST['custom_shipping_options'] = array();
     }
     update_option('custom_shipping_options', array_map('sanitize_text_field', $_POST['custom_shipping_options']));
     $shipadd = 0;
     foreach ($wpsc_shipping_modules as $shipping) {
         foreach ((array) $_POST['custom_shipping_options'] as $shippingoption) {
             if ($shipping->getInternalName() == $shippingoption) {
                 $shipadd++;
             }
         }
     }
     if (isset($_POST['wpsc_options']['shipping_discount_value'])) {
         update_option('shipping_discount_value', wpsc_string_to_float($_POST['wpsc_options']['shipping_discount_value']));
     }
     if (!get_option('do_not_use_shipping') && !get_option('custom_shipping_options') && !(bool) get_option('shipwire')) {
         update_option('do_not_use_shipping', '1');
         return array('shipping_disabled' => 1);
     } else {
         $_SERVER['REQUEST_URI'] = esc_url_raw(remove_query_arg('shipping_disabled'));
     }
 }
コード例 #21
0
 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @codeCoverageIgnore
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     // Check for required params.
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     /**
      * Check for the allowed query vars and set defaults.
      *
      * @see WP_REST_oEmbed_Controller::register_routes()
      */
     $url = esc_url_raw(get_query_var('url'));
     $format = sanitize_text_field(get_query_var('format', 'json'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @param int $maxwidth Maximum allowed width. Defaults to 600.
      *
      * @return int
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = get_query_var('maxwidth', $maxwidth);
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
コード例 #22
0
ファイル: kirki.php プロジェクト: TheSkin/skin-toolkit-plugin
 function kirki_filtered_url()
 {
     $config = apply_filters('kirki/config', array());
     if (isset($config['url_path'])) {
         Kirki::$url = esc_url_raw($config['url_path']);
     }
 }
コード例 #23
0
ファイル: client-js.php プロジェクト: vickoman/client-js
/**
 * Plugin Name: WP-API Client JS
 */
function json_api_client_js()
{
    $scripts = wp_scripts();
    $src = plugins_url('build/js/wp-api.js', __FILE__);
    if (isset($scripts->registered['wp-api'])) {
        $scripts->registered['wp-api']->src = $src;
    } else {
        wp_register_script('wp-api', $src, array('jquery', 'underscore', 'backbone'), '1.0', true);
    }
    /**
     * @var \WP_REST_Server $wp_rest_server
     */
    global $wp_rest_server;
    if (empty($wp_rest_server)) {
        /** This filter is documented in wp-includes/rest-api.php */
        $wp_rest_server_class = apply_filters('wp_rest_server_class', 'WP_REST_Server');
        $wp_rest_server = new $wp_rest_server_class();
        /** This filter is documented in wp-includes/rest-api.php */
        do_action('rest_api_init', $wp_rest_server);
    }
    $schema_request = new WP_REST_Request('GET', '/wp/v2');
    $schema_response = $wp_rest_server->dispatch($schema_request);
    $schema = null;
    if (!$schema_response->is_error()) {
        $schema = $schema_response->get_data();
    }
    $settings = array('root' => esc_url_raw(get_rest_url()), 'nonce' => wp_create_nonce('wp_rest'), 'versionString' => 'wp/v2/', 'schema' => $schema);
    wp_localize_script('wp-api', 'wpApiSettings', $settings);
}
    public function to_html()
    {
        $settings = $this->data['settings'];
        $fields = array('plugin_enabled' => array('id' => 'plugin_enabled', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Content Protection', 'membership2'), 'desc' => __('This setting toggles the content protection on this site.', 'membership2'), 'value' => MS_Plugin::is_enabled(), 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_TOGGLE_SETTINGS, 'setting' => 'plugin_enabled')), 'hide_admin_bar' => array('id' => 'hide_admin_bar', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Hide admin toolbar', 'membership2'), 'desc' => __('Hide the admin toolbar for non administrator users.', 'membership2'), 'value' => $settings->hide_admin_bar, 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_TOGGLE_SETTINGS, 'setting' => 'hide_admin_bar')));
        $fields = apply_filters('ms_view_settings_prepare_general_fields', $fields);
        $setup = MS_Factory::create('MS_View_Settings_Page_Setup');
        $action_url = esc_url_raw(remove_query_arg(array('msg')));
        ob_start();
        MS_Helper_Html::settings_tab_header();
        ?>

		<form action="<?php 
        echo esc_url($action_url);
        ?>
" method="post" class="cf">
			<div class="cf">
				<div class="ms-half">
					<?php 
        MS_Helper_Html::html_element($fields['plugin_enabled']);
        ?>
				</div>
				<div class="ms-half">
					<?php 
        MS_Helper_Html::html_element($fields['hide_admin_bar']);
        ?>
				</div>
			</div>
			<?php 
        MS_Helper_Html::html_separator();
        MS_Helper_Html::html_element($setup->html_full_form());
        ?>
		</form>
		<?php 
        return ob_get_clean();
    }
コード例 #25
0
ファイル: functions.php プロジェクト: ahmedghazi/tpls
function et_divi_load_fonts()
{
    $fonts_url = et_divi_fonts_url();
    if (!empty($fonts_url)) {
        wp_enqueue_style('divi-fonts', esc_url_raw($fonts_url), array(), null);
    }
}
コード例 #26
0
/**
 * Get details about a specific video by GUID:
 *
 * @param $guid string
 * @return object
 */
function videopress_get_video_details($guid)
{
    if (!videopress_is_valid_guid($guid)) {
        return new WP_Error('bad-guid-format', __('Invalid Video GUID!', 'jetpack'));
    }
    $version = '1.1';
    $endpoint = sprintf('/videos/%1$s', $guid);
    $query_url = sprintf('https://public-api.wordpress.com/rest/v%1$s%2$s', $version, $endpoint);
    // Look for data in our transient. If nothing, let's make a new query.
    $data_from_cache = get_transient('jetpack_videopress_' . $guid);
    if (false === $data_from_cache) {
        $response = wp_remote_get(esc_url_raw($query_url));
        $data = json_decode(wp_remote_retrieve_body($response));
        // Cache the response for an hour.
        set_transient('jetpack_videopress_' . $guid, $data, HOUR_IN_SECONDS);
    } else {
        $data = $data_from_cache;
    }
    /**
     * Allow functions to modify fetched video details.
     *
     * This filter allows third-party code to modify the return data
     * about a given video.  It may involve swapping some data out or
     * adding new parameters.
     *
     * @since 4.0.0
     *
     * @param object $data The data returned by the WPCOM API. See: https://developer.wordpress.com/docs/api/1.1/get/videos/%24guid/
     * @param string $guid The GUID of the VideoPress video in question.
     */
    return apply_filters('videopress_get_video_details', $data, $guid);
}
コード例 #27
0
ファイル: customizer.php プロジェクト: AthelasPeru/oniros
/**
 * Sanitize URIs
 */
function oniros_sanitize_uri($uri)
{
    if ('' === $uri) {
        return '';
    }
    return esc_url_raw($uri);
}
コード例 #28
0
ファイル: Abstract.php プロジェクト: nullify005/shcc-website
 /**
  * Compile the schema.org event data into an array
  */
 public function get_data($post = null, $args = array())
 {
     if (!$post instanceof WP_Post) {
         $post = Tribe__Main::post_id_helper($post);
     }
     $post = get_post($post);
     if (!$post instanceof WP_Post) {
         return array();
     }
     $data = (object) array();
     // We may need to prevent the context to be triggered
     if (!isset($args['context']) || false !== $args['context']) {
         $data->{'@context'} = 'http://schema.org';
     }
     $data->{'@type'} = $this->type;
     $data->name = esc_js(get_the_title($post));
     $data->description = esc_js(tribe_events_get_the_excerpt($post));
     if (has_post_thumbnail($post)) {
         $data->image = wp_get_attachment_url(get_post_thumbnail_id($post));
     }
     $data->url = esc_url_raw(get_permalink($post));
     // Index by ID: this will allow filter code to identify the actual event being referred to
     // without injecting an additional property
     return array($post->ID => $data);
 }
コード例 #29
0
ファイル: custom-header.php プロジェクト: sb-xs/que-pour-elle
/**
 * Load our special font CSS file.
 *
 * @since Twenty Twelve 1.2
 */
function twentytwelve_custom_header_fonts()
{
    $font_url = twentytwelve_get_font_url();
    if (!empty($font_url)) {
        wp_enqueue_style('twentytwelve-fonts', esc_url_raw($font_url), array(), null);
    }
}
コード例 #30
0
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags($new_instance['title']);
     $instance['customer_logo'] = esc_url_raw($new_instance['customer_logo']);
     return $instance;
 }