Skip to content

Instantly share code, notes, and snippets.

View enqtran's full-sized avatar

enqtran enqtran

View GitHub Profile
<?php
if (!function_exists('post_type_filters')) {
function post_type_filters()
{
global $typenow;
if ($typenow == 'plans' || $typenow == 'reviews' || $typenow == 'news') {
$posts = get_posts(array('numberposts' => -1));
echo '<select name="shopid">';
echo '<option value="">All Shop</option>';
foreach ($posts as $post) {
<?php
if ( !function_exists( 'parse_query_useronly' ) ) {
function parse_query_useronly($wp_query) {
if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/edit.php') !== false) {
if (!current_user_can('update_core')) {
global $current_user;
$wp_query->set('author', $current_user->id);
}
}
}
<?php
/**
* WordPress Query Reference
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
*/
$args = array(
/**
* Author
*/
'author' => 1,2,3, // lấy dữ liệu theo author id
/**
* [force_post_title_init]
*/
function force_post_title_init() {
wp_enqueue_script('jquery');
}
function force_post_title() {
echo "<script>jQuery('#publish').click(function(){
var testervar = jQuery('[id^=titlediv]').find('#title');
if (testervar.val().length < 1)
/**
* show bubble news
*/
if ( !function_exists( 'add_news_menu_bubble' ) ) {
function add_news_menu_bubble() {
if ( current_user_can('administrator') ) {
global $menu;
$count = wp_count_posts( $post_type ='news' );
$private_count = $count->pending;
if ( $count ) {
**
* remove menu admin.
*/
if ( !function_exists( 'remove_menus' ) ) {
function remove_menus() {
if ( !current_user_can('administrator') ) {
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'users.php' );
remove_menu_page( 'edit-comments.php' );
remove_menu_page( 'upload.php' ); //Media
/**
* remove unwanted dashboard widgets for relevant users
*/
if ( !function_exists( 'remove_dashboard_widgets' ) ) {
function remove_dashboard_widgets() {
$user = wp_get_current_user();
if (!$user->has_cap('manage_options')) {
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
/**
* Hide update for user
*/
if ( ! function_exists( 'hide_update_notice_to_all_users' ) ) {
function hide_update_notice_to_all_users() {
if (!current_user_can('update_core')) {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
add_action( 'admin_head', 'hide_update_notice_to_all_users' );
/**
* Image size.
*/
function image_web_thumb()
{
// Image pickup slider
add_image_size('thumb-image-130-110',130,110, true);
// Image pickup slider
/**
* [force_post_title_init]
*/
function force_post_title_init() {
wp_enqueue_script('jquery');
}
function force_post_title() {
echo "<script>jQuery('#publish').click(function(){
var testervar = jQuery('[id^=titlediv]').find('#title');
if (testervar.val().length < 1)