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 | |
/* | |
* @exampple: echo utf_correction('Ù…Øتوای میکس شده و بخش سالم'); | |
* @link: https://stackoverflow.com/questions/48948340/mixed-encoding-and-make-everything-utf-8 | |
**/ | |
function utf_correction(''){ | |
$str_hex = bin2hex($str); | |
$str = hex2bin($str_hex); | |
$fixed = preg_replace_callback( | |
'/\\P{Arabic}+/u', |
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 | |
add_filter('get_user_link', 'remove_link_from_author'); | |
function remove_link_from_author(){ | |
return ""; | |
} | |
add_filter('get_post_text', 'remove_link_from_post'); | |
function remove_link_from_post($content){ | |
$result = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\2", $content); | |
return $result; | |
} |
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 get_admins_user_ids(){ | |
global $wpdb; | |
//Select all users ID | |
$all_users = $wpdb->get_col("SELECT ID FROM $wpdb->users ORDER BY ID"); | |
$adminsArray = array(); | |
foreach ( $all_users as $uid ) { | |
//Get all users that have administrator role | |
if(get_userdata($uid)->roles[0] == 'administrator'){ | |
$adminsArray[] = $uid; |
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( | |
'label' => '', // Text in Label | |
'placeholder' => '', // Default placeholder | |
'class' => '', // Class of input | |
'style' => '', // Inline style | |
'wrapper_class' => '', // Class of input wrapper | |
'value' => '', // If value goes empty, it retrieved from post meta where id is the meta_key | |
'id' => '', // Required | |
'name' => '', // If name goes empty, it will set from id |
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 | |
add_action( 'wp_dashboard_setup', 'my_custom_dashboard' ); | |
function my_custom_dashboard() { | |
global $wp_meta_boxes; | |
wp_add_dashboard_widget( 'mycustomwidget', 'My Custom Widget', 'display_mycustomwidget' ); | |
} | |
function display_mycustomwidget() { |
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 | |
add_filter('views_edit-post','morteza_custom_filter_for_views_edit'); | |
function morteza_custom_filter_for_views_edit( $views ) { | |
$views['all'] = 'Hell Admin!'; | |
return $views; | |
} |
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 https://developer.wordpress.org/reference/functions/get_post_meta/ | |
**/ | |
// Only for post types | |
if( get_post_meta( $post_id, '_meta_key', true ) ) { | |
// do something | |
} |
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 namespace GM\WWWPostThumbnail; | |
/** | |
* Plugin Name: WWW Post Thumbnail | |
* Description: Allow to use an external image url as featured image. | |
* Plugin URI: https://gist.github.com/Giuseppe-Mazzapica/928bc22e5f49a654cf7c | |
* Author: Giuseppe Mazzapica | |
* Author URI: https://github.com/Giuseppe-Mazzapica | |
* License: MIT | |
* Version: 0.1.0 | |
* |