• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_sample_permalink函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_sample_permalink函数的典型用法代码示例。如果您正苦于以下问题:PHP get_sample_permalink函数的具体用法?PHP get_sample_permalink怎么用?PHP get_sample_permalink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_full_permalink

/**
 * Return the full permalink of the current post.
 * @return string
 */
function get_full_permalink()
{
    $permalinkArray = get_sample_permalink($post->ID);
    $permalinkTemplate = array_values($permalinkArray);
    $permalinkSlug = array_values($permalinkArray);
    return str_replace('%postname%', $permalinkSlug[1], $permalinkTemplate[0]);
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:11,代码来源:edit.php


示例2: script

    public function script()
    {
        global $post;
        if (!isset($post)) {
            return;
        }
        $options = get_wpseo_options();
        $date = '';
        if ($post->post_type == 'post' && (!isset($options['disabledatesnippet']) || !$options['disabledatesnippet'])) {
            $date = $this->get_post_date($post);
            $this->wpseo_meta_length = $this->wpseo_meta_length - (strlen($date) + 5);
            $this->wpseo_meta_length_reason = __(' (because of date display)', 'wordpress-seo');
        }
        $this->wpseo_meta_length_reason = apply_filters('wpseo_metadesc_length_reason', $this->wpseo_meta_length_reason);
        $this->wpseo_meta_length = apply_filters('wpseo_metadesc_length', $this->wpseo_meta_length);
        unset($date);
        $title_template = '';
        if (isset($options['title-' . $post->post_type])) {
            $title_template = $options['title-' . $post->post_type];
        }
        // If there's no title template set, use the default, otherwise title preview won't work.
        if ($title_template == '') {
            $title_template = '%%title%% - %%sitename%%';
        }
        $title_template = wpseo_replace_vars($title_template, $post, array('%%title%%'));
        $metadesc_template = '';
        if (isset($options['metadesc-' . $post->post_type])) {
            $metadesc_template = wpseo_replace_vars($options['metadesc-' . $post->post_type], $post, array('%%excerpt%%', '%%excerpt_only%%'));
        }
        $sample_permalink = get_sample_permalink($post->ID);
        $sample_permalink = str_replace('%page', '%post', $sample_permalink[0]);
        ?>
		<script type="text/javascript">
			var wpseo_lang ='<?php 
        echo substr(get_locale(), 0, 2);
        ?>
';
			var wpseo_meta_desc_length = '<?php 
        echo $this->wpseo_meta_length;
        ?>
';
			var wpseo_title_template = '<?php 
        echo esc_attr($title_template);
        ?>
';
			var wpseo_metadesc_template = '<?php 
        echo esc_attr($metadesc_template);
        ?>
';
			var wpseo_permalink_template = '<?php 
        echo $sample_permalink;
        ?>
';
			var wpseo_keyword_suggest_nonce = '<?php 
        echo wp_create_nonce('wpseo-get-suggest');
        ?>
';
		</script>
		<?php 
    }
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:60,代码来源:class-metabox.php


示例3: fix_permalink

function fix_permalink($ID)
{
    $short_codes = array('pt_br', 'en_us', 'es_es');
    list($permalink, $post_name) = get_sample_permalink($ID, null, null);
    $original_slug = $post_name;
    if (!wp_is_post_revision($post_id)) {
        remove_action('save_post', 'fix_permalink');
        foreach ($short_codes as $sc) {
            $pos_sc = strpos($original_slug, $sc);
            if ($pos_sc === FALSE) {
                //avoid return 0 as a valid position
                $found_short_codes[] = 10000;
            } else {
                $found_short_codes[] = $pos_sc;
            }
        }
        if (array_sum($found_short_codes) < 30000) {
            array_multisort($found_short_codes, $short_codes);
            $extracted_text = explode($short_codes[0], $original_slug);
            $new_slug = $extracted_text[1];
        } else {
            $new_slug = $original_slug;
        }
        $update_slug = array('ID' => $ID, 'post_name' => $new_slug);
        wp_update_post($update_slug);
        add_action('save_post', 'fix_permalink');
    }
}
开发者ID:aspto,项目名称:wordpress-themes,代码行数:28,代码来源:functions.php


示例4: custom_permalink_get_sample_permalink_html

/**
 * Per-post/page options (Wordpress > 2.9)
 *
 * @package CustomPermalinks
 * @since 0.6
 */
function custom_permalink_get_sample_permalink_html($html, $id, $new_title, $new_slug)
{
    $permalink = get_post_meta($id, 'custom_permalink', true);
    $post =& get_post($id);
    ob_start();
    ?>
	<?php 
    custom_permalinks_form($permalink, $post->post_type == "page" ? custom_permalinks_original_page_link($id) : custom_permalinks_original_post_link($id), false);
    ?>
	<?php 
    $content = ob_get_contents();
    ob_end_clean();
    if ('publish' == $post->post_status) {
        $view_post = 'page' == $post->post_type ? __('View Page') : __('View Post');
    }
    if (preg_match("@view-post-btn.*?href='([^']+)'@s", $html, $matches)) {
        $permalink = $matches[1];
    } else {
        list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
        if (false !== strpos($permalink, '%postname%') || false !== strpos($permalink, '%pagename%')) {
            $permalink = str_replace(array('%pagename%', '%postname%'), $post_name, $permalink);
        }
    }
    return '<strong>' . __('Permalink:') . "</strong>\n" . $content . (isset($view_post) ? "<span id='view-post-btn'><a href='{$permalink}' class='button' target='_blank'>{$view_post}</a></span>\n" : "");
}
开发者ID:Giordano-Bruno,项目名称:GiordanoBruno,代码行数:31,代码来源:custom-permalinks.php


示例5: get_sample_permalink_html

/**
 * Returns the HTML of the sample permalink slug editor.
 *
 * @since 2.5.0
 *
 * @param int|object $id Post ID or post object.
 * @param string $new_title Optional. New title.
 * @param string $new_slug Optional. New slug.
 * @return string The HTML of the sample permalink slug editor.
 */
function get_sample_permalink_html($id, $new_title = null, $new_slug = null)
{
    $post = get_post($id);
    if (!$post) {
        return '';
    }
    list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
    if ('publish' == get_post_status($post)) {
        $ptype = get_post_type_object($post->post_type);
        $view_post = $ptype->labels->view_item;
        $title = __('Click to edit this part of the permalink');
    } else {
        $title = __('Temporary permalink. Click to edit this part.');
    }
    if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
        $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
        if ('' == get_option('permalink_structure') && current_user_can('manage_options') && !('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) {
            $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
        }
        if (isset($view_post)) {
            $return .= "<span id='view-post-btn'><a href='{$permalink}' class='button button-small'>{$view_post}</a></span>\n";
        }
        $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
        return $return;
    }
    if (function_exists('mb_strlen')) {
        if (mb_strlen($post_name) > 30) {
            $post_name_abridged = mb_substr($post_name, 0, 14) . '&hellip;' . mb_substr($post_name, -14);
        } else {
            $post_name_abridged = $post_name;
        }
    } else {
        if (strlen($post_name) > 30) {
            $post_name_abridged = substr($post_name, 0, 14) . '&hellip;' . substr($post_name, -14);
        } else {
            $post_name_abridged = $post_name;
        }
    }
    $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
    $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, $permalink);
    $view_link = str_replace(array('%pagename%', '%postname%'), $post_name, $permalink);
    $return = '<strong>' . __('Permalink:') . "</strong>\n";
    $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
    $return .= '&lrm;';
    // Fix bi-directional text display defect in RTL languages.
    $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
    $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
    if (isset($view_post)) {
        $return .= "<span id='view-post-btn'><a href='{$view_link}' class='button button-small'>{$view_post}</a></span>\n";
    }
    $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
    return $return;
}
开发者ID:openify,项目名称:wordpress-composer,代码行数:63,代码来源:post.php


示例6: get_sample_permalink_html

/**
 * Returns the HTML of the sample permalink slug editor.
 *
 * @since 2.5.0
 *
 * @param int    $id        Post ID or post object.
 * @param string $new_title Optional. New title. Default null.
 * @param string $new_slug  Optional. New slug. Default null.
 * @return string The HTML of the sample permalink slug editor.
 */
function get_sample_permalink_html($id, $new_title = null, $new_slug = null)
{
    $post = get_post($id);
    if (!$post) {
        return '';
    }
    list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
    if (current_user_can('read_post', $post->ID)) {
        $ptype = get_post_type_object($post->post_type);
        $view_post = $ptype->labels->view_item;
    }
    if ('publish' == get_post_status($post)) {
        $title = __('Click to edit this part of the permalink');
    } else {
        $title = __('Temporary permalink. Click to edit this part.');
    }
    if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
        $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
        if ('' == get_option('permalink_structure') && current_user_can('manage_options') && !('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) {
            $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
        }
    } else {
        if (function_exists('mb_strlen')) {
            if (mb_strlen($post_name) > 30) {
                $post_name_abridged = mb_substr($post_name, 0, 14) . '&hellip;' . mb_substr($post_name, -14);
            } else {
                $post_name_abridged = $post_name;
            }
        } else {
            if (strlen($post_name) > 30) {
                $post_name_abridged = substr($post_name, 0, 14) . '&hellip;' . substr($post_name, -14);
            } else {
                $post_name_abridged = $post_name;
            }
        }
        $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
        $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, urldecode($permalink));
        $return = '<strong>' . __('Permalink:') . "</strong>\n";
        $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
        $return .= '&lrm;';
        // Fix bi-directional text display defect in RTL languages.
        $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
        $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
    }
    if (isset($view_post)) {
        if ('draft' == $post->post_status) {
            $preview_link = set_url_scheme(get_permalink($post->ID));
            /** This filter is documented in wp-admin/includes/meta-boxes.php */
            $preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post);
            $return .= "<span id='view-post-btn'><a href='" . esc_url($preview_link) . "' class='button button-small' target='wp-preview-{$post->ID}'>{$view_post}</a></span>\n";
        } else {
            $return .= "<span id='view-post-btn'><a href='" . get_permalink($post) . "' class='button button-small'>{$view_post}</a></span>\n";
        }
    }
    /**
     * Filter the sample permalink HTML markup.
     *
     * @since 2.9.0
     *
     * @param string      $return    Sample permalink HTML markup.
     * @param int|WP_Post $id        Post object or ID.
     * @param string      $new_title New sample permalink title.
     * @param string      $new_slug  New sample permalink slug.
     */
    $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
    return $return;
}
开发者ID:GaryJones,项目名称:dockerfiles,代码行数:77,代码来源:post.php


示例7: calculate_results

 /**
  * Calculate the page analysis results for post.
  *
  * @param object $post Post to calculate the results for.
  * @return array
  */
 function calculate_results($post)
 {
     $options = get_wpseo_options();
     if (!class_exists('DOMDocument')) {
         $result = new WP_Error('no-domdocument', sprintf(__("Your hosting environment does not support PHP's %sDocument Object Model%s.", 'wordpress-seo'), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.", 'wordpress-seo'));
         return $result;
     }
     if (!wpseo_get_value('focuskw', $post->ID)) {
         $result = new WP_Error('no-focuskw', sprintf(__('No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'wordpress-seo'), $post->post_type));
         wpseo_set_value('linkdex', 0, $post->ID);
         return $result;
     }
     $results = array();
     $job = array();
     $sampleurl = get_sample_permalink($post);
     $job["pageUrl"] = preg_replace('/%(post|page)name%/', $sampleurl[1], $sampleurl[0]);
     $job["pageSlug"] = urldecode($post->post_name);
     $job["keyword"] = trim(wpseo_get_value('focuskw'));
     $job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
     $job["post_id"] = $post->ID;
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     @$dom->loadHTML($post->post_content);
     $xpath = new DOMXPath($dom);
     $statistics = new Yoast_TextStatistics();
     // Check if this focus keyword has been used already.
     $this->check_double_focus_keyword($job, $results);
     // Keyword
     $this->score_keyword($job['keyword'], $results);
     // Title
     if (wpseo_get_value('title')) {
         $job['title'] = wpseo_get_value('title');
     } else {
         if (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] != '') {
             $title_template = $options['title-' . $post->post_type];
         } else {
             $title_template = '%%title%% - %%sitename%%';
         }
         $job['title'] = wpseo_replace_vars($title_template, (array) $post);
     }
     $this->score_title($job, $results, $statistics);
     // Meta description
     $description = '';
     if (wpseo_get_value('metadesc')) {
         $description = wpseo_get_value('metadesc');
     } else {
         if (isset($options['metadesc-' . $post->post_type]) && !empty($options['metadesc-' . $post->post_type])) {
             $description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
         }
     }
     $meta_length = apply_filters('wpseo_metadesc_length', 156, $post);
     $this->score_description($job, $results, $description, $statistics, $meta_length);
     unset($description);
     // Body
     $body = $this->get_body($post);
     $firstp = $this->get_first_paragraph($post);
     $this->score_body($job, $results, $body, $firstp, $statistics);
     unset($body);
     unset($firstp);
     // URL
     $this->score_url($job, $results, $statistics);
     // Headings
     $headings = $this->get_headings($post->post_content);
     $this->score_headings($job, $results, $headings);
     unset($headings);
     // Images
     $imgs = array();
     $imgs['count'] = substr_count($post->post_content, '<img');
     $imgs = $this->get_images_alt_text($post, $imgs);
     $this->score_images_alt_text($job, $results, $imgs);
     unset($imgs);
     // Anchors
     $anchors = $this->get_anchor_texts($xpath);
     $count = $this->get_anchor_count($xpath);
     $this->score_anchor_texts($job, $results, $anchors, $count);
     unset($anchors, $count, $dom);
     $results = apply_filters('wpseo_linkdex_results', $results, $job, $post);
     $this->aasort($results, 'val');
     $overall = 0;
     $overall_max = 0;
     foreach ($results as $result) {
         $overall += $result['val'];
         $overall_max += 9;
     }
     if ($overall < 1) {
         $overall = 1;
     }
     $score = round($overall / $overall_max * 100);
     wpseo_set_value('linkdex', absint($score), $post->ID);
     return $results;
 }
开发者ID:macosxvn,项目名称:techheroes,代码行数:98,代码来源:class-metabox.php


示例8: WPSR_render_meta_box

function WPSR_render_meta_box($post)
{
    global $wpdb, $table_prefix, $util;
    $table_name = $table_prefix . 'WP_SEO_Redirection';
    if (get_post_status() != 'auto-draft') {
        $permalink = "";
        if (in_array($post->post_status, array('draft', 'pending'))) {
            list($permalink, $postname) = get_sample_permalink($post->ID);
            $permalink = str_replace('%postname%', $postname, $permalink);
        } else {
            $permalink = get_permalink($post->ID);
        }
        $permalink = $util->make_relative_url($permalink);
        $postID = $post->ID;
        $theurl = $wpdb->get_row(" select redirect_to,redirect_from from {$table_name} where postID='{$postID}'  ");
        $urlredirect_to = '';
        if ($wpdb->num_rows > 0) {
            $urlredirect_to = $theurl->redirect_to;
        }
        if ($urlredirect_to != '' && $theurl->redirect_from != $permalink) {
            // the post_name field changed!
            $wpdb->query(" update {$table_name} set redirect_from='{$permalink}'  where postID='{$postID}' ");
            if ($util->get_option_value('reflect_modifications') == '1') {
                $wpdb->query(" update {$table_name} set redirect_to='{$permalink}'  where redirect_to='" . $theurl->redirect_from . "' ");
                $util->info_option_msg('<b>SEO Redirection</b> has detected a change in Permalink, this will be reflected to the redirection records!');
            }
            //-------------------------------------------
        }
        echo '
<table border="0" width="100%" cellpadding="2">
	<tr>
		<td width="99%"><input onchange="redirect_check_click()" type="checkbox" name="redirect_check"  id="redirect_check" value="ON">
		Redirect&nbsp;<font color="#008000">' . $permalink . '</font><input type="hidden" name="wp_seo_redirection_url_from" value="' . $permalink . '"></td>
	</tr>
</table>
<div id="redirect_frame">
<table border="0" width="100%" cellpadding="2">
	<tr>
		<td><b>Redirect to</b> <input type="text" name="wp_seo_redirection_url" id="wp_seo_redirection_url" value="' . $urlredirect_to . '" size="62"></td>
	</tr>
	<tr>
		<td>
		<ul>
			<li>To make a redirection, put the full <b>URL</b> including <b>\'http://\'</b> in the text field above and then click the button <b>Update</b>.</li>
			<li>If you have a caching plugin installed, clear cache to reflect the
			changes immediately.</li>

			<li>To remove the redirection, just uncheck the check box above and then click the button <b>Update</b>.</li>
		</ul>
		</td>
	</tr>
</table>
</div>';
        echo "\n\n<script type='text/javascript'>\nfunction WSR_check_status(x)\n{\n\tif(x==0)\n\t{\n\t\tdocument.getElementById('redirect_check').checked=false;\n\t\tdocument.getElementById('redirect_frame').style.display = 'none';\n\t\tdocument.getElementById('wp_seo_redirection_url').value='';\n\t}else\n\t{\n\t   \tdocument.getElementById('redirect_check').checked=true;\n\t   \tdocument.getElementById('redirect_frame').style.display= 'block';\n\t}\n\n}\n\nfunction redirect_check_click()\n{\n\tif(document.getElementById('redirect_check').checked)\n\tWSR_check_status(1);\n\telse\n\tWSR_check_status(0);\n}\n</script>\n";
        if ($urlredirect_to == '') {
            echo "<script type='text/javascript'>WSR_check_status(0);</script>";
        } else {
            echo "<script type='text/javascript'>WSR_check_status(1);</script>";
        }
    } else {
        echo 'You can not make a redirection for the new posts before saving them.';
    }
}
开发者ID:nhathong1204,项目名称:bdshungthinh,代码行数:63,代码来源:seo-redirection.php


示例9: output

 function output($post)
 {
     global $wpseo_metabox;
     $options = get_wpseo_options();
     if (is_int($post)) {
         $post = get_post($post);
     }
     if (!$post) {
         return;
     }
     if (!class_exists('DOMDocument')) {
         $output = '<div class="wpseo_msg"><p><strong>' . __('Error') . ':</strong> ' . sprintf(__("your hosting environment does not support PHP's %sDocument Object Model%s."), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.") . '</p></div>';
         return $output;
     }
     if (!wpseo_get_value('focuskw')) {
         $output = '<div class="wpseo_msg"><p><strong>' . __('Error') . ':</strong> ' . __("you have not specified a focus keyword, you'll have to enter one, then save or update this post, before this report works.") . '</p></div>';
         return $output;
     }
     $output = '<div class="wpseo_msg"><p><strong>' . __('Note') . ':</strong> ' . __('to update this page analysis, save as draft or update and check this tab again') . '.</p></div>';
     $results = '';
     $job = array();
     $sampleurl = get_sample_permalink($post->ID);
     $job["pageUrl"] = str_replace('%postname%', $sampleurl[1], $sampleurl[0]);
     $job["pageSlug"] = urldecode($post->post_name);
     $job["keyword"] = wpseo_get_value('focuskw');
     $job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     @$dom->loadHTML($post->post_content);
     $xpath = new DOMXPath($dom);
     $statistics = new TextStatistics();
     // Keyword
     $this->ScoreKeyword($job, $results);
     // Title
     if (wpseo_get_value('title')) {
         $title = wpseo_get_value('title');
     } else {
         if (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] != '') {
             $title_template = $options['title-' . $post->post_type];
         } else {
             $title_template = '%%title%% - %%sitename%%';
         }
         $title = wpseo_replace_vars($title_template, (array) $post);
     }
     $this->ScoreTitle($job, $results, $title, $statistics);
     unset($title);
     // Meta description
     $description = '';
     if (wpseo_get_value('metadesc')) {
         $description = wpseo_get_value('metadesc');
     } else {
         if (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] != '') {
             $description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
         }
     }
     $this->ScoreDescription($job, $results, $description, $wpseo_metabox->wpseo_meta_length, $statistics);
     unset($description);
     // Body
     $body = $this->GetBody($post);
     $firstp = $this->GetFirstParagraph($post);
     $this->ScoreBody($job, $results, $body, $firstp, $statistics);
     unset($body);
     unset($firstp);
     // URL
     $this->ScoreUrl($job, $results, $statistics);
     // Headings
     $headings = $this->GetHeadings($post->post_content);
     $this->ScoreHeadings($job, $results, $headings);
     unset($headings);
     // Images
     $alts = $this->GetImagesAltText($post->post_content);
     $imgs = $this->GetImageCount($dom, $xpath);
     $this->ScoreImagesAltText($job, $results, $alts, $imgs);
     unset($alts);
     unset($imgs);
     // Anchors
     $anchors = $this->GetAnchorTexts($dom, $xpath);
     $count = $this->GetAnchorCount($dom, $xpath);
     $this->ScoreAnchorTexts($job, $results, $anchors, $count);
     unset($anchors);
     unset($count);
     unset($dom);
     asort($results);
     $output .= '<table class="wpseoanalysis">';
     foreach ($results as $result) {
         $scoreval = substr($result, 0, 1);
         switch ($scoreval) {
             case 1:
             case 2:
             case 3:
                 $score = 'poor';
                 break;
             case 4:
             case 5:
             case 6:
                 $score = 'ok';
                 break;
             case 7:
             case 8:
//.........这里部分代码省略.........
开发者ID:Joshuwar,项目名称:Masterson,代码行数:101,代码来源:linkdex.php


示例10: insert

 public function insert(&$obj)
 {
     // Incluir post do evento
     /* @var $wpdb wpdb */
     $values = array('post_title' => $obj->titulo, 'post_status' => 'publish', 'post_type' => 'tgo_evento', 'post_date' => 'current_timestamp', 'post_date_gmt' => 'current_timestamp');
     $filter = function_exists('wp_db_null_value') ? 'wp_db_null_value' : 'DB::wpDbNullValue';
     add_filter('query', $filter);
     $ok = $this->wpdb()->insert($this->tableName, $values);
     if ($ok === false) {
         throw new \Exception($this->wpdb()->last_error);
     }
     $id = $this->wpdb()->insert_id;
     remove_filter('query', $filter);
     $evento = $this->getById($id);
     // Obter permalink
     get_sample_permalink($id, $evento->titulo);
     $post_id = $id;
     // Descricao2
     meta_update($post_id, 'descricao_2', false);
     meta_update($post_id, 'descricao_3', false);
     // Publico Alvo
     meta_update($post_id, 'publico_alvo');
     // Local
     meta_update($post_id, 'id_local', false);
     // Organizador
     if (get_option('singleOrganizer', true) && get_option('idSingleOrganizer', null) != null) {
         update_post_meta($post_id, 'id_organizador', get_option('idSingleOrganizer'));
     } else {
         meta_update($post_id, 'id_organizador', false);
     }
     meta_update($post_id, 'data');
     meta_update($post_id, 'hora');
     meta_update($post_id, 'data_fim');
     meta_update($post_id, 'hora_fim');
     meta_update($post_id, 'vagas');
     meta_update($post_id, 'pago');
     meta_update($post_id, 'valor');
     return $this->getById($id);
 }
开发者ID:TiagoGouvea,项目名称:event-manager-plugin-wordpress,代码行数:39,代码来源:Eventos.class.php


示例11: fix_get_sample_permalink_html

 /**
  * Hack to work around post status check in get_sample_permalink_html
  * 
  * 
  * The get_sample_permalink_html checks the status of the post and if it's
  * a draft generates a certain permalink structure.
  * We need to do the same work it's doing for custom statuses in order
  * to support this link
  * @see https://core.trac.wordpress.org/browser/tags/4.5.2/src/wp-admin/includes/post.php#L1296
  *
  * @since 0.8.2
  * 
  * @param string  $return    Sample permalink HTML markup
  * @param int 	  $post_id   Post ID
  * @param string  $new_title New sample permalink title
  * @param string  $new_slug  New sample permalink kslug
  * @param WP_Post $post 	 Post object
  */
 function fix_get_sample_permalink_html($return, $post_id, $new_title, $new_slug, $post)
 {
     $status_slugs = wp_list_pluck($this->get_custom_statuses(), 'slug');
     list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
     $view_link = false;
     $preview_target = '';
     if (current_user_can('read_post', $post_id)) {
         if (in_array($post->post_status, $status_slugs)) {
             $view_link = $this->get_preview_link($post);
             $preview_target = " target='wp-preview-{$post->ID}'";
         } else {
             if ('publish' === $post->post_status || 'attachment' === $post->post_type) {
                 $view_link = get_permalink($post);
             } else {
                 // Allow non-published (private, future) to be viewed at a pretty permalink.
                 $view_link = str_replace(array('%pagename%', '%postname%'), $post->post_name, $permalink);
             }
         }
     }
     // Permalinks without a post/page name placeholder don't have anything to edit
     if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
         $return = '<strong>' . __('Permalink:') . "</strong>\n";
         if (false !== $view_link) {
             $display_link = urldecode($view_link);
             $return .= '<a id="sample-permalink" href="' . esc_url($view_link) . '"' . $preview_target . '>' . $display_link . "</a>\n";
         } else {
             $return .= '<span id="sample-permalink">' . $permalink . "</span>\n";
         }
         // Encourage a pretty permalink setting
         if ('' == get_option('permalink_structure') && current_user_can('manage_options') && !('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) {
             $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
         }
     } else {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($post_name) > 34) {
                 $post_name_abridged = mb_substr($post_name, 0, 16) . '&hellip;' . mb_substr($post_name, -16);
             } else {
                 $post_name_abridged = $post_name;
             }
         } else {
             if (strlen($post_name) > 34) {
                 $post_name_abridged = substr($post_name, 0, 16) . '&hellip;' . substr($post_name, -16);
             } else {
                 $post_name_abridged = $post_name;
             }
         }
         $post_name_html = '<span id="editable-post-name">' . $post_name_abridged . '</span>';
         $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, urldecode($permalink));
         $return = '<strong>' . __('Permalink:') . "</strong>\n";
         $return .= '<span id="sample-permalink"><a href="' . esc_url($view_link) . '"' . $preview_target . '>' . $display_link . "</a></span>\n";
         $return .= '&lrm;';
         // Fix bi-directional text display defect in RTL languages.
         $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __('Edit permalink') . '">' . __('Edit') . "</button></span>\n";
         $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
     }
     return $return;
 }
开发者ID:philoserf,项目名称:Edit-Flow,代码行数:75,代码来源:custom-status.php


示例12: uci_display_permalink_metabox

function uci_display_permalink_metabox($post)
{
    $permalink = get_permalink($post->ID);
    if (in_array($post->post_status, array('draft', 'pending', 'auto-draft'))) {
        require_once ABSPATH . '/wp-admin/includes/post.php';
        list($permalink, $postname) = get_sample_permalink($post->ID);
        $permalink = str_replace('%pagename%', $postname, $permalink);
    }
    ?>
    <script type="text/javascript">
        jQuery(document).on('focus', '#<?php 
    echo UCI_META_PERMALINK;
    ?>
:text', function(e) {
            jQuery(this).select();
        }).on('mouseup', '#<?php 
    echo UCI_META_PERMALINK;
    ?>
:text', function(e) {
            e.preventDefault();
        });
    </script>
    <input style="width:100%;" type="text" name="<?php 
    echo UCI_META_PERMALINK;
    ?>
" id="<?php 
    echo UCI_META_PERMALINK;
    ?>
" value="<?php 
    echo $permalink;
    ?>
" />
    <?php 
}
开发者ID:quantegy,项目名称:wp-news-smart-mag-child,代码行数:34,代码来源:functions.php


示例13: get_sample_permalink_html

    /**
     * Output the permalink editing form with the option to fully customise the
     * slug alongside the default editing option.
     *
     * NOTE: A custom filter is applied here, allowing you to modify the
     * permalink structure via external plugins by adding a filter:
     * add_filter( 'get_custom_permalink_sample', 'callback_function', 1, 2 );
     *
     * @param string $html
     * @param int|object $id
     * @param string $new_title
     * @param string $new_slug
     */
    function get_sample_permalink_html($html, $id, $new_title, $new_slug)
    {
        $post =& get_post($id);
        // Get the current original...
        list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
        // Define the home url...
        $home_url = home_url('/');
        // Fetch the default permalink...
        $this->remove_filters($this->individual_permalink_filters);
        list($default, ) = get_sample_permalink($post->ID);
        // Build the default permalink and replace any tokens...
        $default_permalink = apply_filters('get_custom_permalink_sample', $this->build_permalink($default, $post_name), $post);
        $this->add_filters($this->individual_permalink_filters);
        // Set the permalink to the new one...
        if (isset($_REQUEST['custom_slug'])) {
            $custom_slug = $this->reformat_permalink($_REQUEST['custom_slug'], '');
            if (!empty($custom_slug) && !$this->permalinks_match($custom_slug, $default_permalink)) {
                $post_name = $this->unique_custom_permalink($post->ID, $custom_slug);
                $permalink = $home_url . $post_name;
            } else {
                $permalink = $default;
            }
        } else {
            if ($new_slug) {
                $permalink = $default;
            } else {
                if ($custom = get_post_meta($id, '_' . $this->tag, true)) {
                    $post_name = ltrim($custom, '/');
                    $permalink = $home_url . $post_name;
                }
            }
        }
        // By default we will display the permalink as it is...
        $view_link = $permalink;
        // Fetch the post type label and set the edit title...
        if ('publish' == $post->post_status) {
            $post_type = get_post_type_object($post->post_type);
            $view_post = $post_type->labels->view_item;
            $title = __('Click to edit this part of the permalink');
        } else {
            $title = __('Temporary permalink. Click to edit this part.');
        }
        // Run the permalink through our custom filter...
        $permalink = apply_filters('get_custom_permalink_sample', remove_accents($permalink), $post);
        // Highlight the post name in the permalink...
        $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name . '</span>';
        ob_start();
        ?>
		<strong><?php 
        _e('Permalink:');
        ?>
</strong>
		<?php 
        if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
            $display_link = str_replace($permalink, $post_name_html, $view_link);
            ?>
			<?php 
            echo $home_url;
            ?>
<span id="sample-permalink"><?php 
            echo $display_link;
            ?>
</span>
		<?php 
        } else {
            $view_link = $home_url . $this->build_permalink($permalink, $post_name);
            $display_link = $this->build_permalink($permalink, $post_name_html);
            ?>
			<?php 
            echo $home_url;
            ?>
<span id="sample-permalink"><?php 
            echo $display_link;
            ?>
</span>
			&lrm;
			<span id="edit-slug-buttons">
				<a href="#post_name"
					class="edit-slug button hide-if-no-js"
					onclick="editOriginalPermalink(<?php 
            echo $id;
            ?>
); return false;"><?php 
            _e('Edit');
            ?>
</a>
			</span>
//.........这里部分代码省略.........
开发者ID:t3patterson,项目名称:RSK-WP-Site,代码行数:101,代码来源:index.php


示例14: get_sample_permalink

 /**
  * @ticket 5305
  */
 public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict()
 {
     global $wp_rewrite;
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%month%/%day%/%postname%/');
     $wp_rewrite->flush_rules();
     $p = $this->factory->post->create(array('post_name' => '30'));
     $found = get_sample_permalink($p);
     $this->assertEquals('30', $found[1]);
     $wp_rewrite->set_permalink_structure('');
     flush_rewrite_rules();
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:15,代码来源:includesPost.php


示例15: get_permalink_suggestions

 /**
  * Get extra post permalink suggestions
  * @return array	array of permalink suggestions: 'permalink_URL', 'suggested_slug'
  */
 public function get_permalink_suggestions($title)
 {
     $suggestions = array();
     list($suggestions['permalink_URL'], $suggestions['suggested_slug']) = get_sample_permalink($this->post->ID, $title);
     return $suggestions;
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:10,代码来源:class.json-api-post-base.php


示例16: calculate_results

 /**
  * Calculate the page analysis results for post.
  *
  * @todo [JRF => whomever] check whether the results of this method are always checked with is_wp_error()
  * @todo [JRF => whomever] check the usage of this method as it's quite intense/heavy, see if it's only
  * used when really necessary
  * @todo [JRF => whomever] see if we can get rid of the passing by reference of $results as it makes
  * the code obfuscated
  *
  * @param  object $post Post to calculate the results for.
  *
  * @return  array|WP_Error
  */
 function calculate_results($post)
 {
     $options = WPSEO_Options::get_all();
     if (!class_exists('DOMDocument')) {
         $result = new WP_Error('no-domdocument', sprintf(__("Your hosting environment does not support PHP's %sDocument Object Model%s.", 'wordpress-seo'), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.", 'wordpress-seo'));
         return $result;
     }
     if (!is_array($post) && !is_object($post)) {
         $result = new WP_Error('no-post', __('No post content to analyse.', 'wordpress-seo'));
         return $result;
     } elseif (self::get_value('focuskw', $post->ID) === '') {
         $result = new WP_Error('no-focuskw', sprintf(__('No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'wordpress-seo'), $post->post_type));
         self::set_value('linkdex', 0, $post->ID);
         return $result;
     } elseif (apply_filters('wpseo_use_page_analysis', true) !== true) {
         $result = new WP_Error('page-analysis-disabled', sprintf(__('Page Analysis has been disabled.', 'wordpress-seo'), $post->post_type));
         return $result;
     }
     $results = array();
     $job = array();
     $sampleurl = get_sample_permalink($post);
     $job['pageUrl'] = preg_replace('`%(?:post|page)name%`', $sampleurl[1], $sampleurl[0]);
     $job['pageSlug'] = urldecode($post->post_name);
     $job['keyword'] = self::get_value('focuskw');
     $job['keyword_folded'] = $this->strip_separators_and_fold($job['keyword']);
     $job['post_id'] = $post->ID;
     $job['post_type'] = $post->post_type;
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     /**
      * Filter: 'wpseo_pre_analysis_post_content' - Make the post content filterable before calculating the page analysis
      *
      * @api string $post_content The post cont 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_sample_permalink_html函数代码示例发布时间:2022-05-15
下一篇:
PHP get_samedomain_htsrv_url函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap