Skip to content

Instantly share code, notes, and snippets.

View man4toman's full-sized avatar
:octocat:
A Bit Git!

Morteza Geransayeh man4toman

:octocat:
A Bit Git!
View GitHub Profile
@man4toman
man4toman / hook-to-tablenav.php
Last active October 18, 2018 13:36
Customized WordPress Administration Filters
<?php
add_action( 'restrict_manage_posts', 'wpse45436_admin_posts_filter_restrict_manage_posts' );
function wpse45436_admin_posts_filter_restrict_manage_posts(){
$type = 'post';
if (isset($_GET['post_type'])) {
$type = $_GET['post_type'];
}
if ('POST_TYPE' == $type){
$values = array(
<?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;
}
@man4toman
man4toman / dashboard-custom-widget.php
Created October 22, 2018 09:48
Add custom widget to WordPress dashboard
<?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() {
@man4toman
man4toman / wc-text-input.php
Created October 24, 2018 09:25
Woocommerce text input
<?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
@man4toman
man4toman / admins-ids.php
Last active March 15, 2019 12:01
Finding WordPress Administrator User IDs
<?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;
@man4toman
man4toman / link-remover.php
Created July 5, 2019 14:53
Remove links from Topic Authors/Post Ccontent in standalone bbPress
@man4toman
man4toman / utf-correction.php
Last active July 31, 2019 08:47
Mixed encoding and make everything UTF-8
<?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',
@man4toman
man4toman / blob2utf8.sql
Created October 16, 2018 13:12
Convert blob strings to utf8
#Note: This commands convert pure blob strings to utf8, if you use this commands on mixed strings, they didn't works as expected
alter table sending_info change message message LONGTEXT CHARACTER SET latin1;
alter table sending_info change message message LONGBLOB;
alter table sending_info change message message LONGTEXT CHARACTER SET utf8;
//Credit to Stoyan Stefanov
location = location
location = location
location = location.href
location = window.location
location = self.location
location = window.location.href
location = self.location.href
location = location['href']
@man4toman
man4toman / gist:4ffa6c3d1e6598156a507cb60d6cb9f5
Created November 24, 2019 10:56
Fix RTL Stretch(full-width) row in WPBakery Page Builder(Visual Composer) - CSS solution
body.rtl .vc_row[data-vc-full-width] {
position: relative;
width: 100vw !important;
right: 50% !important;
left: auto !important;
transform: translateX(50%) !important;
padding-left: calc( (100vw - 1140px) / 2 ) !important;
padding-right: calc( (100vw - 1140px) / 2 ) !important;
}
@media(max-width:767px){