This file contains hidden or 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 | |
// Display Trash depending on where and who - and for last | |
function trash_action( $actions, $post ) { | |
global $post, $typenow; | |
$user_id = get_current_user_id(); | |
$user_data = get_userdata($user_id); | |
// Can this user see the Trash link? | |
$my_custom_roles_array = array('custom-role-1', 'custom-role-2'); |
This file contains hidden or 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 | |
// Custom View in action row | |
function change_post_row_actions( $actions, $post ) { | |
unset( $actions['view'] ); | |
$actions['view'] .= '<a href="'.get_the_permalink($post->ID).'" target="_blank">View</a>'; | |
return $actions; | |
} | |
add_filter( 'post_row_actions', 'change_post_row_actions', 10, 2 ); | |
add_filter( 'page_row_actions', 'change_post_row_actions', 10, 2 ); |
This file contains hidden or 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 | |
// Requires the duplicate_content() function | |
// https://gist.github.com/Jany-M/ba36a0499e4fb505105e | |
// Add link to create a cloned CHILD of this post, to action list for post_row_actions | |
function duplicate_content_link( $actions, $post ) { | |
global $typenow; | |
$user_id = get_current_user_id(); | |
$user_data = get_userdata($user_id); |
This file contains hidden or 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 & Save New Permalink if post title was changed | |
function update_slug_on_edit( $data, $postarr ) { | |
global $post; | |
$id = $post->ID; | |
$status = $post->post_status; | |
$cpt = get_post_type($id); | |
$parent = $post->post_parent; |
This file contains hidden or 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 | |
// This will display Gists as if they were real WP posts, so you can display them mixed with real ones too | |
// This will NOT add the Gists as real posts in your DB, you won't see them in your backend | |
/* -------------------------------------- | |
| | |
| Real Posts Loop | |
| | |
|---------------------------------------*/ |
This file contains hidden or 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 | |
// Flush Cache from Admin bar | |
function flush_memcache_button() { | |
global $wp_admin_bar; | |
// If User isnt even logged in or if admin bar is disabled | |
if ( !is_user_logged_in() || !is_admin_bar_showing() ) | |
return false; |
This file contains hidden or 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 | |
// Get a user Access Token (or Page Token if you're the page admin) | |
// https://developers.facebook.com/tools/explorer/145634995501895/ | |
function get_fb_likes($what) { | |
$token = 'your_token_here'; | |
//delete_transient('cached_fb'); | |
if(false === ( $cached_fb_results = get_transient( 'cached_fb' ))) { | |
$json_url = 'https://graph.facebook.com/v2.5/'.$what.'?fields=likes&access_token='.$token; | |
$json = file_get_contents($json_url); |
This file contains hidden or 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 | |
// Duplicate function | |
function duplicate_content(){ | |
global $wpdb; | |
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_content' == $_REQUEST['action'] ) ) ) { | |
wp_die('No post to duplicate has been supplied!'); | |
} | |
// Get original ID |
This file contains hidden or 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 | |
$i = 0; | |
$num = 30; | |
$offset = 30; | |
$cpt = 'rate-plan'; | |
$qty = '1,2,3,4,5,6,7,8,9,10,11,12'; | |
$times = explode(',', $qty); | |
foreach($times as $item) { | |
$i++; |