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
add_action( 'admin_menu', function(){ | |
add_menu_page( 'Empty Page', // The text to be displayed in the title tags of the page when the menu is selected. | |
'New Page', // The text to be used for the menu. | |
'manage_options', // The capability required for this menu to be displayed to the user. | |
'site-options', // The slug name to refer to this menu by (should be unique for this menu). | |
'add_my_setting', // The function to be called to output the content for this page. | |
'', // The URL to the icon to be used for this menu. | |
4 ); // The position in the menu order this one should appear. |
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 plural_form( $number, $after) { | |
$cases = array (2, 0, 1, 1, 1, 2); | |
echo $number.' '.$after[ ($number%100>4 && $number%100<20) ? 2: $cases[min($number%10, 5)] ]; | |
} | |
?> | |
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 creates post duplicate as a draft and redirects then to the edit post screen | |
*/ | |
function rd_duplicate_post_as_draft(){ | |
global $wpdb; | |
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) { | |
wp_die('No post to duplicate has been supplied!'); | |
} |
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
/** | |
* Add our field to the comment form | |
*/ | |
add_action( 'comment_form_logged_in_after', 'pmg_comment_tut_fields' ); | |
add_action( 'comment_form_after_fields', 'pmg_comment_tut_fields' ); | |
function pmg_comment_tut_fields() | |
{ | |
?> | |
<p class="comment-form-title"> | |
<label for="pmg_comment_title"><?php _e( 'Title' ); ?></label> |
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
$('li.menu-item-has-children').click( function(){ | |
subMenu = $('ul', this); | |
if( subMenu.is(":visible") ) | |
{ | |
subMenu.slideUp(); | |
} | |
else | |
{ |
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
function checkNested(obj /*, level1, level2, ... levelN*/) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
for (var i = 0; i < args.length; i++) { | |
if (!obj || !obj.hasOwnProperty(args[i])) { | |
return false; | |
} | |
obj = obj[args[i]]; | |
} | |
return true; |
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
function getNested(obj, deepKey, delimiter = '.') { | |
let args = deepKey.split(delimiter); | |
for (let i = 0; i < args.length; i++) { | |
if (!obj || !obj.hasOwnProperty(args[i])) { | |
return undefined; | |
} | |
obj = obj[args[i]]; | |
} | |
return obj; |