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 | |
/** | |
* For a list of all actions, see wp-nested-pages/app/Entities/PostType/PostTypeRepository, line 97 | |
*/ | |
// Hide/Show the "WPML" link if installed | |
add_filter('nestedpages_row_action_wpml', 'nestedPagesWpmlLink', 10, 2); | |
function nestedPagesWpmlLink($include, $post_type) | |
{ | |
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
<?php | |
/** | |
* Add the link post type to the query args passed to the listing query | |
*/ | |
add_filter('nestedpages_page_listing', 'nestedpages_add_links_to_listing', 10, 2); | |
function nestedpages_add_links_to_listing($query_args, $post_type) | |
{ | |
if ( $post_type->name == 'custom-post-type' ) $query_args['post_type'][] = 'np-redirect'; | |
return $query_args; | |
} |
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 | |
// Method 1: simple foreach loop | |
$favorites = get_user_favorites(); | |
if ( isset($favorites) && !empty($favorites) ) : | |
foreach ( $favorites as $favorite ) : | |
// You'll have access to the post ID in this foreach loop, so you can use WP functions like get_the_title($favorite); | |
endforeach; | |
endif; |
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
/** | |
* In this example, we're adding a custom "acf/carousel" block to the array of supported block types for block animations | |
* We've added this JS file to the script dependencies required by the plugin, using the wp_block_animations_script_dependencies hook. | |
* Additionally, when enqueueing this file, we've added `wp-hooks` as a dependency to ensure the global object is available | |
*/ | |
wp.hooks.addFilter( | |
'wp_block_animations_allowed_blocks', | |
'allowed_blocks', | |
addCustomBlockAnimations |
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('wp_block_animations_script_dependencies', 'blockAnimationDependencies); | |
/** | |
* We are adding our custom script containing our addFilter reference to the plugin dependencies. | |
* This way, we ensure the plugin scripts run after we add our filter | |
*/ | |
function blockAnimationDependencies($deps) | |
{ | |
$deps[] = 'custom-script-handle'; |
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
/** | |
* favorites-updated-single | |
* Fires after a favorite button has been submitted successfully | |
* @param favorites - Array of post objects the user has favorited | |
* @param post_id - The post ID that was updated | |
* @param site_id - The site ID for the post that was updated (for multisite) | |
* @param status - Whether the button was active or inactive | |
*/ | |
$(document).on('favorites-updated-single', function(event, favorites, post_id, site_id, status){ | |
// Do stuff here as needed. |
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('nestedpages_row_parent_css_classes', 'nestedpages_filter_row_css_classes', 10, 3); | |
/** | |
* Filter the <li> element css classes for nested pages rows | |
* @param str - $row_classes - the CSS classes for output | |
* @param obj - $post - the current post object | |
* @param obj - $post_type_object - the current post type object | |
*/ | |
function nestedpages_filter_row_css_classes($row_classes, $post, $post_type_object) | |
{ |
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_filter('simplefavorites_user_list', 'filter_favorites_user_list', 10, 3); | |
function filter_favorites_user_list($output, $users, $anonymous_count) | |
{ | |
$output = '<ul>'; | |
foreach($users as $user){ | |
$output .= '<li><a href="' . site_url() . '/members/' . $user->user_login . '">' . $user->display_name . '</a></li>'; | |
} | |
$output .= '</ul>'; | |
$output .= '(+' . $anonymous_count . ' Anonymous Users)'; | |
return $output; |
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
/** | |
* Place in your theme's functions.php | |
*/ | |
add_action('admin_head', 'hide_nested_pages_add_multiple'); | |
function hide_nested_pages_add_multiple() | |
{ | |
$user = wp_get_current_user(); | |
$allowed_roles = ['administrator']; | |
if ( array_intersect($allowed_roles, $user->roles) ) return; | |
echo '<style>.open-bulk-modal, .nestedpages .action-buttons .nestedpages-dropdown ul li a.add-new-child, .nestedpages .action-buttons .nestedpages-dropdown ul li:nth-child(2) {display:none;}</style>'; |
NewerOlder