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 | |
add_action('admin_init', 'foo_duplicate_posts', 99999); | |
function foo_duplicate_posts(){ | |
// Only allow admins to run the script | |
if(!current_user_can('manage_options')) | |
return; | |
// Check if keyword is set | |
if(!isset($_GET['duplicate-posts'])) |
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
/** | |
* Redirect Visitors To Login Page | |
* | |
* @author Zo Rizvi | |
* | |
* @uses template_redirect() Template Redirect action hook | |
* @uses is_user_logged_in() conditional tag | |
* @uses is_page() conditional tag | |
* @uses is_front_page() conditional tag | |
* @uses wp_redirect() WP Redirect function |
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
/** | |
* Redirect Logged Out Users To Homepage | |
* | |
* @uses template_redirect() Template Redirect action hook | |
* @uses is_user_logged_in() conditional tag | |
* @uses is_page() conditional tag | |
* @uses is_front_page() conditional tag | |
* @uses wp_redirect() WP Redirect function | |
* @uses home_url() Home URL function | |
* |
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
/** | |
* Redirect Logged Out Users To Homepage | |
* | |
* @uses template_redirect() Template Redirect action hook | |
* @uses is_user_logged_in() conditional tag | |
* @uses is_page() conditional tag | |
* @uses is_front_page() conditional tag | |
* @uses wp_redirect() WP Redirect function | |
* | |
*/ |
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
//Custom Search on Homepage | |
function custom_search_where($where){ | |
global $wpdb; | |
if (is_search() && get_search_query()) | |
$where .= "OR ((t.name LIKE '%".get_search_query()."%' OR t.slug LIKE '%".get_search_query()."%') AND {$wpdb->posts}.post_status = 'publish')"; | |
return $where; | |
} | |
function custom_search_join($join){ | |
global $wpdb; |
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
//Custom Autocomplete | |
add_action('wp_ajax_nopriv_get_listing_names', 'ajax_listings'); | |
add_action('wp_ajax_get_listing_names', 'ajax_listings'); | |
function ajax_listings() { | |
global $wpdb; //get access to the WordPress database object variable | |
//get names of all taxonomy terms | |
$name = '%'.$wpdb->esc_like(stripslashes($_GET['name'])).'%'; //escape for use in LIKE statement | |
$sql = "SELECT term.term_id as id, term.name as post_title, term.slug as guid, tax.taxonomy FROM $wpdb->term_taxonomy tax |
NewerOlder