add_filter( 'ajax_query_attachments_args', 'restrict_media_search_function', 10, 1 );
function restrict_media_search_function( $query )
{
// если при поиске ввели менее 5 символов вставляем невозможное слово
// для поиска что бы возвращался пустой запрос и не подгружались картинки
if (array_key_exists('s', $query) && strlen($query['s']) < 5)
$query['s'] = "bad@word@for@search";
return $query;
}
add_filter( 'admin_init', 'restrict_media_search_function' );
function restrict_media_search_function ( )
{
$action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
$action = !empty( $_POST['action'] ) ? $_POST['action'] : '';
if ( $action === 'query-attachments' )
{
$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
if (array_key_exists('s', $query) && strlen($query['s']) < 5)
die( '1' );
}
}
/%post_id%.html
/%post_id%-post.html
$args = array(
'numberposts' => 1
,'offset' => 0
,'orderby' => 'post_date'
,'order' => 'DESC'
,'post_type' => 'post'
// выбрать то что нужно
,'post_status' => 'draft, pending'
,'suppress_filters' => true
);
function get_comments_count_function( $user_id ) {
global $wpdb;
$count = $wpdb->get_var(
'SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. '
WHERE user_id = ' . $user_id . '
AND comment_approved = "1"
AND comment_type IN ("comment", "")'
);
return $count;
}
add_action( 'edit_comment', 'check_comments_qty_function', 10, 2 );
function check_comments_qty_function( $comment_ID, $data ) {
$user = get_userdatabylogin( $data['comment_author'] );
// больше двух опубликованных комментария?
if (get_comments_count_function( $user->ID ) > 1)
{
$user = new WP_User( $user->ID );
// не администратор и подписчик
if ( !$user->has_cap( 'administrator' ) && $user->has_cap( 'subscriber' ))
{
$user->remove_role( 'subscriber' );
$user->add_role( 'editor' );
}
}
}
<?php
if(have_posts()) :
while(have_posts()) :
the_post();
?>
<h1><?php the_title() ?></h1>
<div class='post-content'><?php the_content() ?></div>
<?php
endwhile;
else :
?>
Нет постов!
<?php
endif;
?>
...
'exclude_from_search' => false,
'rewrite' => array('slug' => '%hideurl%', 'with_front' => false, 'pages' => false, 'feeds' => false, 'feed' => false),
...
add_filter('post_type_link', 'mytags_permalink', 1, 2);
function mytags_permalink($permalink, $post)
{
if (strpos($permalink, '%hideurl%') === FALSE)
return $permalink;
return site_url();
}
<?php
$data = array();
$data[] = "http://www.site1.ru/";
$data[] = "http://www.site2.ru/";
$data[] = "http://www.site3.ru/";
foreach ($data as $line){
$content = file_get_contents($line);
preg_match("/meta name=\"generator\" content=\"wordpress (.+)\"/i", $content, $result);
echo $line." - ".$result[1]."\n";
}
?>