コード例 #1
0
ファイル: ajax-actions.php プロジェクト: hughnet/WordPress
/**
 * Ajax handler to retrieve a sample permalink.
 *
 * @since 3.1.0
 */
function wp_ajax_sample_permalink()
{
    check_ajax_referer('samplepermalink', 'samplepermalinknonce');
    $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
    $title = isset($_POST['new_title']) ? $_POST['new_title'] : '';
    $slug = isset($_POST['new_slug']) ? $_POST['new_slug'] : null;
    wp_die(get_sample_permalink_html($post_id, $title, $slug));
}
コード例 #2
0
<div id="post-body">
<div id="titlediv">
<h3><?php 
_e('Title');
?>
</h3>
<div id="titlewrap">
	<input type="text" name="post_title" size="30" tabindex="1" value="<?php 
echo attribute_escape($post->post_title);
?>
" id="title" autocomplete="off" />
</div>
<div class="inside">
<?php 
$sample_permalink_html = get_sample_permalink_html($post->ID);
?>
	<div id="edit-slug-box">
<?php 
if (!empty($post->ID) && !empty($sample_permalink_html)) {
    echo $sample_permalink_html;
}
?>
	</div>
</div>
</div>

<div id="<?php 
echo user_can_richedit() ? 'postdivrich' : 'postdiv';
?>
" class="postarea">
コード例 #3
0
if (post_type_supports($post_type, 'title')) {
    ?>
<div id="titlediv">
<div id="titlewrap">
	<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php 
    echo apply_filters('enter_title_here', __('Enter title here'), $post);
    ?>
</label>
	<input type="text" name="post_title" size="30" tabindex="1" value="<?php 
    echo esc_attr(htmlspecialchars($post->post_title));
    ?>
" id="title" autocomplete="off" />
</div>
<div class="inside">
<?php 
    $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
    $shortlink = nxt_get_shortlink($post->ID, 'post');
    if (!empty($shortlink)) {
        $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
    }
    if ($post_type_object->public && !('pending' == $post->post_status && !current_user_can($post_type_object->cap->publish_posts))) {
        ?>
	<div id="edit-slug-box">
	<?php 
        if (!empty($post->ID) && !empty($sample_permalink_html) && 'auto-draft' != $post->post_status) {
            echo $sample_permalink_html;
        }
        ?>
	</div>
<?php 
    }
コード例 #4
0
 /**
  * @ticket 30910
  * @ticket 18306
  */
 public function test_get_sample_permalink_html_should_use_preview_links_for_draft_and_pending_posts_with_no_post_name()
 {
     $this->set_permalink_structure('/%postname%/');
     wp_set_current_user(self::$admin_id);
     $future_date = date('Y-m-d H:i:s', time() + 100);
     $p = self::factory()->post->create(array('post_status' => 'pending', 'post_name' => '', 'post_date' => $future_date));
     $found = get_sample_permalink_html($p);
     $post = get_post($p);
     $this->assertContains('href="' . esc_url(get_preview_post_link($post)), $found);
 }
コード例 #5
0
 /**
  * @ticket 32954
  * @ticket 18306
  */
 public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug()
 {
     $this->set_permalink_structure('/%postname%/');
     wp_set_current_user(self::$admin_id);
     // Published posts should use published permalink
     $p = self::factory()->post->create(array('post_status' => 'publish', 'post_name' => 'foo-صورة'));
     $found = get_sample_permalink_html($p, null, 'new_slug-صورة');
     $post = get_post($p);
     $message = 'Published post';
     $this->assertContains('href="' . get_option('home') . "/" . $post->post_name . '/"', $found, $message);
     $this->assertContains('>new_slug-صورة<', $found, $message);
     // Scheduled posts should use published permalink
     $future_date = date('Y-m-d H:i:s', time() + 100);
     $p = self::factory()->post->create(array('post_status' => 'future', 'post_name' => 'bar-صورة', 'post_date' => $future_date));
     $found = get_sample_permalink_html($p, null, 'new_slug-صورة');
     $post = get_post($p);
     $message = 'Scheduled post';
     $this->assertContains('href="' . get_option('home') . "/" . $post->post_name . '/"', $found, $message);
     $this->assertContains('>new_slug-صورة<', $found, $message);
     // Draft posts should use preview link
     $p = self::factory()->post->create(array('post_status' => 'draft', 'post_name' => 'baz-صورة'));
     $found = get_sample_permalink_html($p, null, 'new_slug-صورة');
     $post = get_post($p);
     $message = 'Draft post';
     $preview_link = get_permalink($post->ID);
     $preview_link = add_query_arg('preview', 'true', $preview_link);
     $this->assertContains('href="' . esc_url($preview_link) . '"', $found, $message);
     $this->assertContains('>new_slug-صورة<', $found, $message);
 }
コード例 #6
0
ファイル: embed.php プロジェクト: ru4/arabbnota
/**
 * Handle saving the permalink via ajax.
 */
function vf_embed_edit_slug()
{
    $post_id = vf_configure_embed_container();
    check_ajax_referer('samplepermalink', 'samplepermalinknonce');
    $slug = isset($_POST['new_slug']) ? $_POST['new_slug'] : null;
    wp_update_post(array('ID' => $post_id, 'post_name' => $slug));
    die(get_sample_permalink_html($post_id, 'Discussion Forum', $slug));
}
コード例 #7
0
     if ($page_columns) {
         update_usermeta($user->ID, "screen_layout_{$page}", $page_columns);
     }
     die('1');
     break;
 case 'get-permalink':
     check_ajax_referer('getpermalink', 'getpermalinknonce');
     $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
     die(add_query_arg(array('preview' => 'true'), get_permalink($post_id)));
     break;
 case 'sample-permalink':
     check_ajax_referer('samplepermalink', 'samplepermalinknonce');
     $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
     $title = isset($_POST['new_title']) ? $_POST['new_title'] : '';
     $slug = isset($_POST['new_slug']) ? $_POST['new_slug'] : '';
     die(get_sample_permalink_html($post_id, $title, $slug));
     break;
 case 'inline-save':
     check_ajax_referer('inlineeditnonce', '_inline_edit');
     if (!isset($_POST['post_ID']) || !($post_ID = (int) $_POST['post_ID'])) {
         exit;
     }
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_ID)) {
             die(__('You are not allowed to edit this page.'));
         }
     } else {
         if (!current_user_can('edit_post', $post_ID)) {
             die(__('You are not allowed to edit this post.'));
         }
     }
コード例 #8
0
	/**
	 * @ticket 30910
	 */
	public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_button_when_pretty_permalinks_are_enabled() {
		global $wp_rewrite;
		$old_permalink_structure = get_option( 'permalink_structure' );
		$permalink_structure = '%postname%';
		$wp_rewrite->set_permalink_structure( "/$permalink_structure/" );
		flush_rewrite_rules();

		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );

		$future_date = date( 'Y-m-d H:i:s', time() + 100 );
		$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );

		$found = get_sample_permalink_html( $p );
		$post = get_post( $p );
		$this->assertContains( "span id='view-post-btn'><a href='" . get_option( 'home' ) . "/" . $post->post_name . "/'", $found );

		$wp_rewrite->set_permalink_structure( $old_permalink_structure );
		flush_rewrite_rules();
	}
if (post_type_supports($post_type, 'title')) {
    ?>
<div id="titlediv">
<div id="titlewrap">
	<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php 
    echo apply_filters('enter_title_here', __('Enter title here'), $post);
    ?>
</label>
	<input type="text" name="post_title" size="30" tabindex="1" value="<?php 
    echo esc_attr(htmlspecialchars($post->post_title));
    ?>
" id="title" autocomplete="off" />
</div>
<div class="inside">
<?php 
    $sample_permalink_html = !empty($post_type_object->publicly_queryable) ? get_sample_permalink_html($post->ID) : '';
    $shortlink = wp_get_shortlink($post->ID, 'post');
    if (!empty($shortlink)) {
        $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
    }
    if (!empty($post_type_object->publicly_queryable) && !('pending' == $post->post_status && !current_user_can($post_type_object->cap->publish_posts))) {
        ?>
	<div id="edit-slug-box">
	<?php 
        if (!empty($post->ID) && !empty($sample_permalink_html) && 'auto-draft' != $post->post_status) {
            echo $sample_permalink_html;
        }
        ?>
	</div>
<?php 
    }
コード例 #10
0
function vanilla_embed_options()
{
    $PostID = embed_vanilla_configure_container();
    if (isset($_POST['save'])) {
        if (function_exists('current_user_can') && !current_user_can('manage_options')) {
            die(__('Permission Denied'));
        }
        $VanillaEmbedCode = stripslashes(array_key_exists('vanilla_embed_code', $_POST) ? $_POST['vanilla_embed_code'] : '');
        update_option('vanilla_embed_code', $VanillaEmbedCode);
    } else {
        $VanillaEmbedCode = stripslashes(get_option('vanilla_embed_code'));
        $VanillaPost = get_post($PostID);
        $VanillaPageName = $VanillaPost->post_title;
    }
    ?>
<script type="text/javascript">
jQuery(document).ready( function($) {
	editPermalink = function(post_id) {
		var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html();
	
		$('#view-post-btn').hide();
		b.html('<a href="#" class="save button">Save</a> <a class="cancel" href="#">Cancel</a>');
		b.children('.save').click(function() {
			var new_slug = e.children('input').val();
			$.post(ajaxurl, {
				action: 'vanilla_embed_edit_slug',
				post_id: post_id,
				new_slug: new_slug,
				new_title: $('#title').val(),
				samplepermalinknonce: $('#samplepermalinknonce').val()
			}, function(data) {
				$('#edit-slug-box').html(data);
				b.html(revert_b);
				real_slug.attr('value', new_slug);
				makeSlugeditClickable();
				$('#view-post-btn').show();
			});
			return false;
		});
	
		$('.cancel', '#edit-slug-buttons').click(function() {
			$('#view-post-btn').show();
			e.html(revert_e);
			b.html(revert_b);
			real_slug.attr('value', revert_slug);
			return false;
		});
	
		for ( i = 0; i < full.length; ++i ) {
			if ( '%' == full.charAt(i) )
				c++;
		}
	
		slug_value = ( c > full.length / 4 ) ? '' : full;
		e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){
			var key = e.keyCode || 0;
			// on enter, just save the new slug, don't save the post
			if ( 13 == key ) {
				b.children('.save').click();
				return false;
			}
			if ( 27 == key ) {
				b.children('.cancel').click();
				return false;
			}
			real_slug.attr('value', this.value);
		}).focus();
	}
	
	makeSlugeditClickable = function() {
		$('#editable-post-name').click(function() {
			$('#edit-slug-buttons').children('.edit-slug').click();
		});
	}
	makeSlugeditClickable();

});
</script>
<style type="text/css">
form strong {
    display: block;
	 padding-top: 10px;
}
#edit-slug-box {
	font-size: 11px;
	padding: 8px;
	margin: 0;
	height: auto;
	background: #fff;
	border: 1px inset #888;
	display: inline-block;
	min-width: 384px;
}
#edit-slug-box strong {
	display: none;
	font-size: 12px;
	color: #333;
}
#editable-post-name input {
	width: 120px;
}
form em {
    display: block;
    color: #555;
    font-size: 11px;
}
textarea,
textarea:focus {
    font-family: monospace;
    color: #000;
    height: 50px;
    width: 400px;
    font-size: 12px;
    line-height: 13px;
    padding: 2px;
    border-radius: 0;
    -moz-border-radius: 0;
    -webkit-border-radius: 0;
    border: 1px inset #888;
}
input.InputBox,
input.InputBox:focus {
    width: 400px;
	 border: 1px solid #888;
}
.GetVanilla {
	padding: 10px 0 26px;
}
.GetVanilla h2 {
	margin: 0;
	padding: 0 0 16px;
}
.GetVanilla a {
   margin: 0;
	box-shadow: 0px 0px 2px #999;
	-moz-box-shadow: 0px 0px 2px #999;
	-webkit-box-shadow: 0px 0px 2px #999;  
   border-radius: 4px;
	-moz-border-radius: 4px;
	-webkit-border-radius: 4px;
	background:url("../wp-content/plugins/EmbedVanilla/bg-button-blue.png") repeat-x scroll left top transparent;
	border:1px solid #0F7FE6;
	color:#003673;
	cursor:pointer;
	font-size:12px;
	font-weight:bold;
	padding:6px 10px 6px 6px;
	text-decoration:none;
	text-shadow:0 1px 0 #B7F5FD;
}
.GetVanilla a span {
	padding-left: 20px;
	background: url('../wp-content/plugins/EmbedVanilla/logo.png') no-repeat 0 0;
}
.GetVanilla a:hover {
	border: 1px solid #0B64C6;
	color: #001F44;
	text-shadow:0 1px 0 #EEFFFF;
}
.GetVanilla a:focus {
	background: #81CFF6;
	border:1px solid #0B64C6;
	color:#001F44;
	text-shadow:0 1px 0 #EEFFFF;
}


</style>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('&lt;Embed&gt; Vanilla');
    ?>
</h2>
	<?php 
    if (isset($_POST['save'])) {
        echo '<div class="updated" id="message"><p>Your changes have been saved.</p></div>';
    }
    ?>
   <p>Use this page to embed your Vanilla Forum into WordPress.</p>
	<?php 
    if (substr($VanillaEmbedCode, 0, 7) != '<script') {
        echo "<div class=\"GetVanilla\">\n\t\t\t<h2>Don't have a Vanilla Forum yet?</h2>\n\t\t\t<a href=\"http://vanillaforums.com\" target=\"_blank\"><span>Get one in under 60 seconds!</span></a>\n\t\t</div>";
    }
    ?>
   <form method="post">
		<strong>Forum &lt;Embed&gt; Code</strong>
		<textarea id="EmbedCode" name="vanilla_embed_code"><?php 
    echo $VanillaEmbedCode;
    ?>
</textarea>
		<em>Paste the forum embed code from your Vanilla forum here.</em>

		<strong>Forum Location in WordPress</strong>
		<em>Define where to access your Vanilla Forum within WordPress.</em>
		<?php 
    /*
    <input type="text" class="InputBox" name="vanilla_page_name" value="<?php echo $VanillaPageName; ?>" />
    */
    ?>
		<div id="edit-slug-box"><?php 
    echo get_sample_permalink_html($PostID);
    ?>
</div>
		<?php 
    wp_nonce_field('samplepermalink', 'samplepermalinknonce', false);
    ?>
		</div>
      <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save &raquo;');
    ?>
" /></p>
   </form>
</div>
<?php 
}
コード例 #11
0
    ?>
	</label></p>
	<?php 
    if (current_user_can('create_posts', 'page')) {
        ?>
	<p class="if-page-for-posts sub-option"><label for="page_for_posts_title"><?php 
        _e('Page title:');
        ?>
		<input name="page_for_posts_title" type="text" id="page_for_posts_title" value="<?php 
        echo esc_attr(htmlspecialchars($page_for_posts->post_title));
        ?>
" />
	</label></p>
	<p class="if-page-for-posts sub-option" id="edit-slug-box">
		<?php 
        echo get_sample_permalink_html($page_for_posts->ID, $page_for_posts->post_title, $page_for_posts->post_name);
        ?>
	</p>
	<input name="post_name" type="hidden" id="post_name" value="<?php 
        echo esc_attr(apply_filters('editable_slug', $page_for_posts->post_name));
        ?>
" />
	<?php 
        if ('page' == get_option('show_on_front') && get_option('page_for_posts') == get_option('page_on_front')) {
            ?>
	<div class="error inline"><p><strong><?php 
            _e('ERROR:');
            ?>
</strong> <?php 
            _e('These pages should not be the same!');
            ?>
コード例 #12
0
 /**
  * Ajax response for changing the language in the post metabox
  *
  * @since 0.2
  */
 public function post_lang_choice()
 {
     check_ajax_referer('pll_language', '_pll_nonce');
     global $post_ID;
     // Obliged to use the global variable for wp_popular_terms_checklist
     $post_id = $post_ID = (int) $_POST['post_id'];
     $lang = $this->model->get_language($_POST['lang']);
     $post_type = $_POST['post_type'];
     $post_type_object = get_post_type_object($post_type);
     if (!current_user_can($post_type_object->cap->edit_post, $post_ID)) {
         wp_die(-1);
     }
     $this->model->post->set_language($post_ID, $lang);
     // Save language, useful to set the language when uploading media from post
     ob_start();
     if ($lang) {
         include PLL_ADMIN_INC . '/view-translations-' . ('attachment' == $post_type ? 'media' : 'post') . '.php';
     }
     $x = new WP_Ajax_Response(array('what' => 'translations', 'data' => ob_get_contents()));
     ob_end_clean();
     // Categories
     if (isset($_POST['taxonomies'])) {
         // Not set for pages
         foreach ($_POST['taxonomies'] as $taxname) {
             $taxonomy = get_taxonomy($taxname);
             ob_start();
             $popular_ids = wp_popular_terms_checklist($taxonomy->name);
             $supplemental['populars'] = ob_get_contents();
             ob_end_clean();
             ob_start();
             // Use $post_ID to remember ckecked terms in case we come back to the original language
             wp_terms_checklist($post_ID, array('taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids));
             $supplemental['all'] = ob_get_contents();
             ob_end_clean();
             $supplemental['dropdown'] = wp_dropdown_categories(array('taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;', 'echo' => 0));
             $x->Add(array('what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental));
         }
     }
     // Parent dropdown list ( only for hierarchical post types )
     if (in_array($post_type, get_post_types(array('hierarchical' => true)))) {
         $post = get_post($post_ID);
         // Args and filter from 'page_attributes_meta_box' in wp-admin/includes/meta-boxes.php of WP 4.2.1
         $dropdown_args = array('post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column' => 'menu_order, post_title', 'echo' => 0);
         /** This filter is documented in wp-admin/includes/meta-boxes.php */
         $dropdown_args = apply_filters('page_attributes_dropdown_pages_args', $dropdown_args, $post);
         // Since WP 3.3
         $x->Add(array('what' => 'pages', 'data' => wp_dropdown_pages($dropdown_args)));
     }
     // Flag
     $x->Add(array('what' => 'flag', 'data' => empty($lang->flag) ? esc_html($lang->slug) : $lang->flag));
     // Sample permalink
     $x->Add(array('what' => 'permalink', 'data' => get_sample_permalink_html($post_ID)));
     $x->send();
 }
コード例 #13
0
    public function RenderEditor()
    {
        global $post, $cb_post;
        //assign the clearbase post object to the wp $post object for this context
        $post = $cb_post;
        foreach ($this->fields as $field) {
            if (!isset($field['type'])) {
                continue;
            }
            if (!isset($field['id'])) {
                $field['id'] = '';
            }
            if (!isset($field['title'])) {
                $field['title'] = isset($field['name']) ? $field['name'] : '';
            }
            if (!isset($field['class'])) {
                $field['class'] = '';
            }
            if (!isset($field['css'])) {
                $field['css'] = '';
            }
            if (!isset($field['default'])) {
                $field['default'] = '';
            }
            if (!isset($field['desc'])) {
                $field['desc'] = '';
            }
            if (!isset($field['desc_tip'])) {
                $field['desc_tip'] = false;
            }
            $convertedID = str_replace('.', '-', $field['id']);
            // Custom attribute handling
            $custom_attributes = array();
            if (!empty($field['custom_attributes']) && is_array($field['custom_attributes'])) {
                foreach ($field['custom_attributes'] as $attribute => $attribute_value) {
                    $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
                }
            }
            // Description handling
            if ($field['desc_tip'] === true) {
                $description = '';
                $tip = $field['desc'];
            } elseif (!empty($field['desc_tip'])) {
                $description = $field['desc'];
                $tip = $field['desc_tip'];
            } elseif (!empty($field['desc'])) {
                $description = $field['desc'];
                $tip = '';
            } else {
                $description = $tip = '';
            }
            if ($description && in_array($field['type'], array('textarea', 'radio'))) {
                $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>';
            } elseif ($description && in_array($field['type'], array('checkbox'))) {
                $description = wp_kses_post($description);
            } elseif ($description) {
                $description = '<span class="description">' . wp_kses_post($description) . '</span>';
            }
            if ($tip && in_array($field['type'], array('checkbox'))) {
                $tip = '<p class="description">' . $tip . '</p>';
            } elseif ($tip) {
                $tip = '<img />';
                //'<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . WC()->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
            }
            // Switch based on type
            switch ($field['type']) {
                // Section Titles
                case 'sectionstart':
                    if (!empty($field['title'])) {
                        echo '<h3>' . esc_html($field['title']) . '</h3>';
                    }
                    if (!empty($field['desc'])) {
                        echo wpautop(wptexturize(wp_kses_post($field['desc'])));
                    }
                    echo '<table class="form-table ' . $field['class'] . '">' . "\n\n";
                    if (!empty($field['id'])) {
                        do_action('clearbase_editor_section_' . sanitize_title($field['id']));
                    }
                    break;
                    // Section Ends
                // Section Ends
                case 'sectionend':
                    if (!empty($field['id'])) {
                        do_action('clearbase_editor_section_' . sanitize_title($field['id']) . '_end');
                    }
                    echo '</table>';
                    if (!empty($field['id'])) {
                        do_action('clearbase_editor_section_' . sanitize_title($field['id']) . '_after');
                    }
                    break;
                case 'post_title':
                    ?>
<tr valign="top">
                    <th scope="row" class="titledesc">
                        <label for="post-post_title"><?php 
                    echo __('Title', 'clearbase');
                    ?>
</label>
                    </th>
                    <td class="forminp forminp-text">
                        <input
                            name="post-post_title"
                            id="post-post_title"
                            type="text"
                            style="min-width: 300px"
                            value="<?php 
                    echo esc_attr($post->post_title);
                    ?>
"
                            class=""
                        /> <?php 
                    //Render the permalink editor
                    $sample_permalink_html = get_sample_permalink_html($post->ID);
                    // $shortlink = wp_get_shortlink($post->ID, 'post');
                    // if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) )
                    //     $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
                    if (!('pending' == get_post_status($post) && !current_user_can($post_type_object->cap->publish_posts))) {
                        $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
                        ?>
                                <div id="edit-slug-box" class="hide-if-no-js">
                                <?php 
                        if ($has_sample_permalink) {
                            echo $sample_permalink_html;
                        }
                        ?>
                                </div>
                            <?php 
                    }
                    ?>
                    </td>
                </tr>
                <tr valign="top" class="hide-if-js">
                    <th scope="row" class="titledesc">
                            <label for="post-post_name"><?php 
                    echo esc_html(__('Slug', 'clearbase'));
                    ?>
</label>
                            <?php 
                    echo $tip;
                    ?>
                    </th>
                    <td class="forminp forminp-text">
                      <input
                        name="post-post_name"
                        id="post-post_name"
                        type="text"
                        style="min-width: 300px"
                        value="<?php 
                    echo esc_attr($post->post_name);
                    ?>
"
                        class=""
                        /> <?php 
                    echo __('Specifies the permalink slug', 'clearbase');
                    ?>
                    </td>
                </tr>
                <?php 
                    break;
                    // Standard text inputs and subtypes like 'number'
                // Standard text inputs and subtypes like 'number'
                case 'text':
                case 'email':
                case 'number':
                case 'color':
                case 'password':
                    $type = $field['type'];
                    $class = '';
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    if ($field['type'] == 'color') {
                        $type = 'text';
                        $field['class'] .= 'colorpick';
                        $description .= '<div id="colorPickerDiv_' . $convertedID . ' " class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
                    }
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
                            <th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
                                    <label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
                                    <?php 
                    echo $tip;
                    ?>
                            </th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<input
	                    		name="<?php 
                    echo $convertedID;
                    ?>
"
	                    		id="<?php 
                    echo $convertedID;
                    ?>
"
	                    		type="<?php 
                    echo esc_attr($type);
                    ?>
"
	                    		style="<?php 
                    echo esc_attr($field['css']);
                    ?>
"
	                    		value="<?php 
                    echo esc_attr($option_value);
                    ?>
"
	                    		class="<?php 
                    echo esc_attr($field['class']);
                    ?>
"
	                    		<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
	                    		/> <?php 
                    echo $description;
                    ?>
	                    </td>
	                </tr><?php 
                    break;
                    // Textarea
                // Textarea
                case 'textarea':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
						<th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
							<label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
							<?php 
                    echo $tip;
                    ?>
						</th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<?php 
                    echo $description;
                    ?>

	                        <textarea
	                        	name="<?php 
                    echo $convertedID;
                    ?>
"
	                        	id="<?php 
                    echo $convertedID;
                    ?>
"
	                        	style="<?php 
                    echo esc_attr($field['css']);
                    ?>
"
	                        	class="<?php 
                    echo esc_attr($field['class']);
                    ?>
"
	                        	<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
	                        	><?php 
                    echo esc_textarea($option_value);
                    ?>
</textarea>
	                    </td>
	                </tr><?php 
                    break;
                    // Select boxes
                // Select boxes
                case 'select':
                case 'multiselect':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
						<th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
							<label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
							<?php 
                    echo $tip;
                    ?>
						</th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<select
	                    		name="<?php 
                    echo $convertedID;
                    if ($field['type'] == 'multiselect') {
                        echo '[]';
                    }
                    ?>
"
	                    		id="<?php 
                    echo $convertedID;
                    ?>
"
	                    		style="<?php 
                    echo esc_attr($field['css']);
                    ?>
"
	                    		class="<?php 
                    echo esc_attr($field['class']);
                    ?>
"
	                    		<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
	                    		<?php 
                    if ($field['type'] == 'multiselect') {
                        echo 'multiple="multiple"';
                    }
                    ?>
	                    		>
		                    	<?php 
                    foreach ($field['options'] as $key => $val) {
                        ?>
			                        	<option value="<?php 
                        echo esc_attr($key);
                        ?>
" <?php 
                        if (is_array($option_value)) {
                            selected(in_array($key, $option_value), true);
                        } else {
                            selected($option_value, $key);
                        }
                        ?>
><?php 
                        echo $val;
                        ?>
</option>
			                        	<?php 
                    }
                    ?>
	                       </select> <?php 
                    echo $description;
                    ?>
	                    </td>
	                </tr><?php 
                    break;
                    // Radio inputs
                // Radio inputs
                case 'radio':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
						<th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
							<label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
							<?php 
                    echo $tip;
                    ?>
						</th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<fieldset>
	                    		<?php 
                    echo $description;
                    ?>
	                    		<ul>
	                    		<?php 
                    foreach ($field['options'] as $key => $val) {
                        ?>
			                        	<li>
			                        		<label><input
				                        		name="<?php 
                        echo $convertedID;
                        ?>
"
				                        		value="<?php 
                        echo $key;
                        ?>
"
				                        		type="radio"
					                    		style="<?php 
                        echo esc_attr($field['css']);
                        ?>
"
					                    		class="<?php 
                        echo esc_attr($field['class']);
                        ?>
"
					                    		<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
					                    		<?php 
                        checked($key, $option_value);
                        ?>
				                        		/> <?php 
                        echo $val;
                        ?>
</label>
			                        	</li>
			                        	<?php 
                    }
                    ?>
	                    		</ul>
	                    	</fieldset>
	                    </td>
	                </tr><?php 
                    break;
                    // Checkbox input
                // Checkbox input
                case 'checkbox':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    $visbility_class = array();
                    if (!isset($field['hide_if_checked'])) {
                        $field['hide_if_checked'] = false;
                    }
                    if (!isset($field['show_if_checked'])) {
                        $field['show_if_checked'] = false;
                    }
                    if ($field['hide_if_checked'] == 'yes' || $field['show_if_checked'] == 'yes') {
                        $visbility_class[] = 'hidden_option';
                    }
                    if ($field['hide_if_checked'] == 'option') {
                        $visbility_class[] = 'hide_options_if_checked';
                    }
                    if ($field['show_if_checked'] == 'option') {
                        $visbility_class[] = 'show_options_if_checked';
                    }
                    if (!isset($field['checkboxgroup']) || 'start' == $field['checkboxgroup']) {
                        ?>
		            		<tr valign="top" class="<?php 
                        echo esc_attr(implode(' ', $visbility_class));
                        echo $field['tr_class'];
                        ?>
">
								<th scope="row" class="titledesc <?php 
                        echo $field['th_class'];
                        ?>
"><?php 
                        echo esc_html($field['title']);
                        ?>
</th>
								<td class="forminp forminp-checkbox <?php 
                        echo $field['td_class'];
                        ?>
">
									<fieldset>
						<?php 
                    } else {
                        ?>
		            		<fieldset class="<?php 
                        echo esc_attr(implode(' ', $visbility_class));
                        ?>
">
	            		<?php 
                    }
                    if (!empty($field['title'])) {
                        ?>
	            			<legend class="screen-reader-text"><span><?php 
                        echo esc_html($field['title']);
                        ?>
</span></legend>
	            		<?php 
                    }
                    ?>
						<label for="<?php 
                    echo $convertedID;
                    ?>
">
							<input
								name="<?php 
                    echo $convertedID;
                    ?>
"
								id="<?php 
                    echo $convertedID;
                    ?>
"
								type="checkbox"
								value="1"
								<?php 
                    checked($option_value, 'yes');
                    ?>
								<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
							/> <?php 
                    echo $description;
                    ?>
						</label> <?php 
                    echo $tip;
                    ?>
					<?php 
                    if (!isset($field['checkboxgroup']) || 'end' == $field['checkboxgroup']) {
                        ?>
									</fieldset>
								</td>
							</tr>
						<?php 
                    } else {
                        ?>
							</fieldset>
						<?php 
                    }
                    break;
                    // Default: run an action
                // Default: run an action
                default:
                    if (is_callable($field['render'])) {
                        call_user_func($field['render'], $field);
                    }
                    do_action('clearbase_editor_field_' . $field['type'], $field);
                    break;
            }
        }
    }
コード例 #14
0
 function test_fix_sample_permalink_html_on_publish_when_pretty_permalinks_are_enabled()
 {
     $this->set_permalink_structure('/%postname%/');
     // Published posts should use published permalink
     $p = self::factory()->post->create(array('post_status' => 'publish', 'post_name' => 'foo-صورة', 'post_author' => self::$admin_user_id));
     wp_set_current_user(self::$admin_user_id);
     $found = get_sample_permalink_html($p, null, 'new_slug-صورة');
     $post = get_post($p);
     $message = 'Published post';
     $this->assertContains('href="' . get_option('home') . "/" . $post->post_name . '/"', $found, $message);
     $this->assertContains('>new_slug-صورة<', $found, $message);
 }
コード例 #15
0
ファイル: edit-item.php プロジェクト: nanbu-collne/test2
function wc2_item_content_info_box()
{
    global $post;
    $wc2_item = WC2_DB_Item::get_instance();
    ?>
<div class="postbox">
<?php 
    //if( post_type_supports( $post->post_type, 'title' ) ) :
    ?>
<div class="inside">
<div class="itempagetitle"><?php 
    _e('ページタイトル:', 'wc2');
    ?>
</div>
<div id="titlediv">
	<div id="titlewrap">
		<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php 
    _e('Enter title here');
    ?>
</label>
		<input type="text" name="post_title" size="30" tabindex="1" value="<?php 
    esc_attr_e(htmlspecialchars($post->post_title));
    ?>
" id="title" autocomplete="off" />
	</div>
<?php 
    $sample_permalink_html = get_sample_permalink_html($post->ID);
    $shortlink = wp_get_shortlink($post->ID, ITEM_POST_TYPE);
    if (!empty($shortlink)) {
        $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
    }
    if (!('pending' == $post->post_status && !current_user_can($post_type_object->cap->publish_posts))) {
        ?>
	<div id="edit-slug-box">
	<?php 
        if (!empty($post->ID) && !empty($sample_permalink_html) && 'auto-draft' != $post->post_status) {
            echo $sample_permalink_html;
        }
        ?>
	</div>
<?php 
    }
    ?>
</div>
<?php 
    wp_nonce_field('samplepermalink', 'samplepermalinknonce', false);
    //endif;
    //if( post_type_supports($post->post_type, 'editor' ) ) :
    ?>
<div class="itempagetitle"><?php 
    _e('商品説明:', 'wc2');
    ?>
</div>
<div id="<?php 
    echo user_can_richedit() ? 'postdivrich' : 'postdiv';
    ?>
" class="postarea">
<style type="text/css">
<!--
.wp_themeSkin table td {
	background-color: white;
}
-->
</style>
<?php 
    wp_editor($post->post_content, 'content', array('dfw' => true, 'tabindex' => 1));
    ?>
<table id="post-status-info" cellspacing="0"><tbody><tr>
	<td id="wp-word-count"></td>
	<td class="autosave-info">
	<span id="autosave">&nbsp;</span>
<?php 
    if ('auto-draft' != $post->post_status) {
        echo '<span id="last-edit">';
        if ($last_id = get_post_meta($post->ID, '_edit_last', true)) {
            $last_user = get_userdata($last_id);
            printf(__('Last edited by %1$s on %2$s at %3$s'), esc_attr($last_user->display_name), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
        } else {
            if (isset($post->post_modified)) {
                printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
            }
        }
        echo '</span>';
    }
    ?>
	</td>
</tr></tbody></table>
</div>
<?php 
    //endif;
    ?>
</div>
</div>
<?php 
}
コード例 #16
0
 /**
  * @ticket 32954
  */
 public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_button_when_changing_slug()
 {
     global $wp_rewrite;
     $old_permalink_structure = get_option('permalink_structure');
     $permalink_structure = '%postname%';
     $wp_rewrite->set_permalink_structure("/{$permalink_structure}/");
     flush_rewrite_rules();
     wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
     // Published posts should use published permalink
     $p = $this->factory->post->create(array('post_status' => 'publish', 'post_name' => 'foo'));
     $found = get_sample_permalink_html($p, null, 'new_slug');
     $post = get_post($p);
     $this->assertContains("span id='view-post-btn'><a href='" . get_option('home') . "/" . $post->post_name . "/'", $found);
     // Scheduled posts should use published permalink
     $future_date = date('Y-m-d H:i:s', time() + 100);
     $p = $this->factory->post->create(array('post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date));
     $found = get_sample_permalink_html($p, null, 'new_slug');
     $post = get_post($p);
     $this->assertContains("span id='view-post-btn'><a href='" . get_option('home') . "/" . $post->post_name . "/'", $found);
     // Draft posts should use preview link
     $p = $this->factory->post->create(array('post_status' => 'draft', 'post_name' => 'baz'));
     $found = get_sample_permalink_html($p, null, 'new_slug');
     $post = get_post($p);
     $preview_link = get_permalink($post->ID);
     $preview_link = add_query_arg('preview', 'true', $preview_link);
     $this->assertContains("span id='view-post-btn'><a href='" . esc_url($preview_link) . "'", $found);
     $wp_rewrite->set_permalink_structure($old_permalink_structure);
     flush_rewrite_rules();
 }