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
function my_admin_help($text, $screen) { | |
// Check we're only on my Settings page | |
if (strcmp($screen, MY_PAGEHOOK) == 0 ) { | |
$text = 'Here is some very useful information to help you use this plugin...'; | |
return $text; | |
} | |
// Let the default WP Dashboard help stuff through on other Admin pages | |
return $text; | |
} |
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
/** | |
* Getting taxonomy from DB without having links | |
* @param $post_id | |
* @return string "tag1,tag3,tag4" | |
*/ | |
function go_get_terms($id){ | |
global $wpdb; | |
$q = 'SELECT * from wp_terms t LEFT JOIN wp_term_relationships r on r.term_taxonomy_id = t.term_id WHERE object_id = '.$id; | |
$rows = $wpdb->get_results($wpdb->prepare($q)); | |
$out = ""; |
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
//If you only want to show directories, replace "-type f" with "-type d". | |
find . -type f -exec du -sk {} \; | sort -nr |
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
UPDATE table_name SET COLUMN = REPLACE(COLUMN, 'old_text', 'new_text'); |
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
useradd -m -d /home/USER_NAME -g wheel USER_NAME | |
usermod -G GROUP1,GROUP2 USER_NAME |
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
sudo service httpd graceful | |
sudo /etc/init.d/apache2 restart | |
sudo /etc/init.d/apache2 stop | |
sudo /etc/init.d/apache2 reload |
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
// First way | |
$('#checkBox').attr('checked'); | |
// Second way | |
$('#edit-checkbox-id').is(':checked'); | |
//input name array | |
$('input[name=SOME_NAME\\[\\]]').is(':checked') |
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
// If the link being clicked is external the user will be prompted | |
// to confirm they wish to leave the site. Confirmation results in | |
// the external link being opened in a new window | |
$('a') | |
.bind('click', function(event) { | |
var a = new RegExp('/' + window.location.host + '/'); | |
if(!a.test(this.href)) { |
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
If you would like to remove a tag along with the text inside it then use the following code. | |
<?php | |
preg_replace('/(<tag>.+?)+(<\/tag>)/i', '', $string); | |
?> | |
example | |
<?php $string='<span class="normalprice">55 PKR</span>'; ?> | |
<?php |
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
/** | |
* Hide ACF menu item from the admin menu | |
*/ | |
function hide_admin_menu() | |
{ | |
global $current_user; | |
get_currentuserinfo(); | |
if($current_user->user_login != 'admin') |