This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @link http://www.wpexplorer.com/useful-wordpress-snippets/ | |
*/ | |
function change_default_title( $title ){ | |
$screen = get_current_screen(); | |
if ( '_your_custom_post_type_' == $screen->post_type ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @link http://wpgarage.com/plugins/how-to-use-jetpacks-sharedaddy-without-connecting-to-wordpress-com/ | |
* Modify plugin file - jetpack-sharedaddy.php | |
* / | |
function hack_jetpack_offline_mode() { | |
if ( ! file_exists( WP_PLUGIN_DIR . '/jetpack/' ) || class_exists( 'Jetpack' ) ) | |
return; | |
require_once( WP_PLUGIN_DIR . '/jetpack/jetpack.php' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change wordpress posts to news | |
* | |
* @link http://new2wp.com/snippet/change-wordpress-posts-post-type-news/ | |
*/ | |
function change_post_menu_label() { | |
global $menu; | |
global $submenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
if(typeof(pagenow) !== 'undefined' && pagenow == 'edit-post') { | |
$('h2 .add-new-h2').after('<a id="data_output" class="add-new-h2" href="?ay_output=excel" target="_blank">輸出 Excel 會員列表</a>'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'labels' => array( | |
'name' => '服務中心', | |
'signular_name' => '服務中心' | |
), | |
'public' => true, | |
'hierarchical' => true, | |
'supports' => array( | |
'title', 'editor', 'page-attributes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set the new image sizes | |
if(function_exists( 'add_image_size')){ | |
add_image_size('blog-large', 900, 700, false); | |
} | |
// Tell the media panel to add the new size to the dropbown | |
function custom_image_sizes($sizes) { | |
$addsizes = array( | |
"blog-large" => __("X-Large") | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="image-list1" class="sortable-list"> | |
<li id="a">A</li> | |
<li id="b">B</li> | |
<li id="c">C</li> | |
</ul> | |
<ul id="image-list2" class="sortable-list"> | |
<li id="1">1</li> | |
<li id="2">2</li> | |
<li id="3">3</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function copy_post_to_blog($post_id, $target_blog_id) { | |
$post = get_post($post_id, ARRAY_A); // get the original post | |
$meta = get_post_meta($post_id); | |
$post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post | |
switch_to_blog($target_blog_id); // switch to target blog | |
$inserted_post_id = wp_insert_post($post); // insert the post | |
foreach($meta as $key=>$value) { | |
update_post_meta($inserted_post_id,$key,$value[0]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable Quick Edit row action for posts | |
* | |
* @see WP_Posts_List_Table::single_row() | |
* | |
* @param array $actions An array of row actions, keys corresponding to the span class attribute of each element. | |
* @param object $post The post object. | |
* | |
* @return array The row actions array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Skip dashboard when log into backend. | |
*/ | |
function my_login_redirect( $redirect_to, $url, $user ) { | |
if ( ! is_wp_error( $user ) && user_can( $user, 'edit_posts' ) ) { | |
$redirect_to = admin_url( 'edit.php' ); | |
} |