当前位置: 首页>>代码示例>>PHP>>正文


PHP WPSEO_Utils::json_encode方法代码示例

本文整理汇总了PHP中WPSEO_Utils::json_encode方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::json_encode方法的具体用法?PHP WPSEO_Utils::json_encode怎么用?PHP WPSEO_Utils::json_encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WPSEO_Utils的用法示例。


在下文中一共展示了WPSEO_Utils::json_encode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_admin

 /**
  * Adding a new admin
  *
  * @param string $admin_name Name string.
  * @param string $admin_id   ID string.
  *
  * @return string
  */
 public function add_admin($admin_name, $admin_id)
 {
     $success = 0;
     // If one of the fields is empty.
     if (empty($admin_name) || empty($admin_id)) {
         $response_body = $this->get_response_body('not_present');
     } else {
         $admin_id = $this->parse_admin_id($admin_id);
         if (!isset($this->options['fb_admins'][$admin_id])) {
             $name = sanitize_text_field(urldecode($admin_name));
             $admin_id = sanitize_text_field($admin_id);
             if (preg_match('/[0-9]+?/', $admin_id) && preg_match('/[\\w\\s]+?/', $name)) {
                 $this->options['fb_admins'][$admin_id]['name'] = $name;
                 $this->options['fb_admins'][$admin_id]['link'] = urldecode('http://www.facebook.com/' . $admin_id);
                 $this->save_options();
                 $success = 1;
                 $response_body = $this->form->get_admin_link($admin_id, $this->options['fb_admins'][$admin_id]);
             } else {
                 $response_body = $this->get_response_body('invalid_format');
             }
         } else {
             $response_body = $this->get_response_body('already_exists');
         }
     }
     return WPSEO_Utils::json_encode(array('success' => $success, 'html' => $response_body));
 }
开发者ID:healthcommcore,项目名称:osnap,代码行数:34,代码来源:class-social-facebook.php

示例2: print_scripts

    /**
     * Prints the pointer script
     *
     * @param string $selector The CSS selector the pointer is attached to.
     * @param array  $options  The options for the pointer.
     */
    public function print_scripts($selector, $options)
    {
        // Button1 is the close button, which always exists.
        $button_array_defaults = array('button2' => array('text' => false, 'function' => ''), 'button3' => array('text' => false, 'function' => ''));
        $this->button_array = wp_parse_args($this->button_array, $button_array_defaults);
        ?>
		<script type="text/javascript">
			//<![CDATA[
			(function ($) {
				// Don't show the tour on screens with an effective width smaller than 1024px or an effective height smaller than 768px.
				if (jQuery(window).width() < 1024 || jQuery(window).availWidth < 1024) {
					return;
				}

				var wpseo_pointer_options = <?php 
        echo WPSEO_Utils::json_encode($options);
        ?>
, setup;

				wpseo_pointer_options = $.extend(wpseo_pointer_options, {
					buttons: function (event, t) {
						var button = jQuery('<a href="<?php 
        echo $this->get_ignore_url();
        ?>
" id="pointer-close" style="margin:0 5px;" class="button-secondary">' + '<?php 
        _e('Close', 'wordpress-seo');
        ?>
' + '</a>');
						button.bind('click.pointer', function () {
							t.element.pointer('close');
						});
						return button;
					},
					close: function () {
					}
				});

				setup = function () {
					$('<?php 
        echo $selector;
        ?>
').pointer(wpseo_pointer_options).pointer('open');
					var lastOpenedPointer = jQuery( '.wp-pointer').slice( -1 );
					<?php 
        $this->button2();
        $this->button3();
        ?>
				};

				if (wpseo_pointer_options.position && wpseo_pointer_options.position.defer_loading)
					$(window).bind('load.wp-pointers', setup);
				else
					$(document).ready(setup);
			})(jQuery);
			//]]>
		</script>
	<?php 
    }
开发者ID:designomx,项目名称:DMXFrmwrk,代码行数:64,代码来源:class-pointers.php

示例3: recalculate_scores

 /**
  * Start recalculation
  */
 public function recalculate_scores()
 {
     check_ajax_referer('wpseo_recalculate', 'nonce');
     $fetch_object = $this->get_fetch_object();
     if (!empty($fetch_object)) {
         $paged = filter_input(INPUT_POST, 'paged', FILTER_VALIDATE_INT);
         $response = $fetch_object->get_items_to_recalculate($paged);
         if (!empty($response)) {
             wp_die(WPSEO_Utils::json_encode($response));
         }
     }
     wp_die('');
 }
开发者ID:Didox,项目名称:beminfinito,代码行数:16,代码来源:class-recalculate-scores-ajax.php

示例4: __toString

 /**
  * Adds string (view) behaviour to the Notification
  *
  * @return string
  */
 public function __toString()
 {
     $attributes = array();
     // Default notification classes.
     $classes = array('yoast-notice', 'notice');
     if (!empty($this->options['type'])) {
         $classes[] = $this->options['type'];
     }
     if ($this->is_persistent()) {
         $attributes['id'] = $this->options['id'];
         $classes[] = 'yoast-dismissible';
         $classes[] = 'is-dismissible';
     }
     if (!empty($classes)) {
         $attributes['class'] = implode(' ', $classes);
     }
     $nonce = $this->get_nonce();
     if (!empty($nonce)) {
         $attributes['data-nonce'] = $nonce;
     }
     if (!empty($this->options['data_json'])) {
         $attributes['data-json'] = WPSEO_Utils::json_encode($this->options['data_json']);
     }
     // Combined attribute key and value into a string.
     array_walk($attributes, array($this, 'parse_attributes'));
     // Build the output DIV.
     return '<div ' . implode(' ', $attributes) . '>' . wpautop($this->message) . '</div>' . PHP_EOL;
 }
开发者ID:designomx,项目名称:DMXFrmwrk,代码行数:33,代码来源:class-yoast-notification.php

示例5: ajax_get_term_keyword_usage

/**
 * Retrieves the keyword for the keyword doubles of the termpages.
 */
function ajax_get_term_keyword_usage()
{
    $post_id = filter_input(INPUT_POST, 'post_id');
    $keyword = filter_input(INPUT_POST, 'keyword');
    $taxonomy = filter_input(INPUT_POST, 'taxonomy');
    wp_die(WPSEO_Utils::json_encode(WPSEO_Taxonomy_Meta::get_keyword_usage($keyword, $post_id, $taxonomy)));
}
开发者ID:healthcommcore,项目名称:osnap,代码行数:10,代码来源:ajax.php

示例6: set_transient

 /**
  * Write the notifications to a cookie (hooked on shutdown)
  */
 public function set_transient()
 {
     // Count local stored notifications.
     if (count($this->notifications) > 0) {
         // Create array with all notifications.
         $arr_notifications = array();
         // Add each notification as array to $arr_notifications.
         foreach ($this->notifications as $notification) {
             $arr_notifications[] = $notification->to_array();
         }
         // Set the cookie with notifications.
         set_transient(self::TRANSIENT_KEY, WPSEO_Utils::json_encode($arr_notifications), MINUTE_IN_SECONDS * 10);
     }
 }
开发者ID:Didox,项目名称:beminfinito,代码行数:17,代码来源:class-yoast-notification-center.php

示例7: update_storage

 /**
  * Save persistent notifications to storage
  *
  * We need to be able to retrieve these so they can be dismissed at any time during the execution.
  *
  * @since 3.2
  *
  * @return void
  */
 public function update_storage()
 {
     $notifications = array_filter($this->notifications, array($this, 'filter_persistent_notifications'));
     // No notifications to store, clear storage.
     if (empty($notifications)) {
         $this->remove_storage();
         return;
     }
     $notifications = array_map(array($this, 'notification_to_array'), $notifications);
     // Save the notifications to the storage.
     update_option(self::STORAGE_KEY, WPSEO_Utils::json_encode($notifications), true);
 }
开发者ID:RCMmedia,项目名称:kuopp,代码行数:21,代码来源:class-yoast-notification-center.php

示例8: taxonomy_metadata

 /**
  * Adds the taxonomy meta data if there is any
  */
 private function taxonomy_metadata()
 {
     if ($this->include_taxonomy) {
         $taxonomy_meta = get_option('wpseo_taxonomy_meta');
         if (is_array($taxonomy_meta)) {
             $this->write_line('[wpseo_taxonomy_meta]', true);
             $this->write_setting('wpseo_taxonomy_meta', urlencode(WPSEO_Utils::json_encode($taxonomy_meta)));
         } else {
             $this->write_line('; ' . __('No taxonomy metadata found', 'wordpress-seo'), true);
         }
     }
 }
开发者ID:Didox,项目名称:beminfinito,代码行数:15,代码来源:class-export.php

示例9: ajax_get_term_keyword_usage

/**
 * Retrieves the keyword for the keyword doubles of the termpages.
 */
function ajax_get_term_keyword_usage()
{
    $post_id = filter_input(INPUT_POST, 'post_id');
    $keyword = filter_input(INPUT_POST, 'keyword');
    $taxonomy = filter_input(INPUT_POST, 'taxonomy');
    if (!current_user_can('edit_terms')) {
        die('-1');
    }
    $usage = WPSEO_Taxonomy_Meta::get_keyword_usage($keyword, $post_id, $taxonomy);
    // Normalize the result so it it the same as the post keyword usage AJAX request.
    $usage = $usage[$keyword];
    wp_die(WPSEO_Utils::json_encode($usage));
}
开发者ID:designomx,项目名称:DMXFrmwrk,代码行数:16,代码来源:ajax.php

示例10: parse_data_json_attribute

 /**
  * Make it possible to pass some JSON data
  *
  * @return string
  */
 private function parse_data_json_attribute()
 {
     if (empty($this->options['data_json'])) {
         return '';
     }
     return " data-json='" . WPSEO_Utils::json_encode($this->options['data_json']) . "'";
 }
开发者ID:Didox,项目名称:beminfinito,代码行数:12,代码来源:class-yoast-notification.php

示例11: output

 /**
  * Outputs the JSON LD code in a valid JSON+LD wrapper
  *
  * @since 1.8
  *
  * @param string $context The context of the output, useful for filtering.
  */
 private function output($context)
 {
     /**
      * Filter: 'wpseo_json_ld_output' - Allows filtering of the JSON+LD output
      *
      * @api array $output The output array, before its JSON encoded
      *
      * @param string $context The context of the output, useful to determine whether to filter or not.
      */
     $this->data = apply_filters('wpseo_json_ld_output', $this->data, $context);
     if (is_array($this->data) && !empty($this->data)) {
         $json_data = WPSEO_Utils::json_encode($this->data);
         echo "<script type='application/ld+json'>", $json_data, '</script>', "\n";
     }
     // Empty the $data array so we don't output it twice.
     $this->data = array();
 }
开发者ID:healthcommcore,项目名称:osnap,代码行数:24,代码来源:class-json-ld.php


注:本文中的WPSEO_Utils::json_encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。