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( 'rest_api_init', 'my_register_route'); | |
function my_register_route() { | |
register_rest_route( 'my-route', 'my-posts/(?P<id>\d+)', array( | |
'methods' => 'GET', | |
'callback' => 'my_posts', | |
'args' => array( | |
'id' => array( | |
'validate_callback' => function( $param, $request, $key ) { |
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 | |
/** | |
* Handles email sending | |
*/ | |
class Custom_Email_Manager { | |
/** | |
* Constructor sets up actions | |
*/ | |
public function __construct() { |
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( 'rest_api_init', 'my_register_route'); | |
function my_register_route() { | |
register_rest_route( 'my-route', 'my-posts', array( | |
'methods' => 'GET', | |
'callback' => 'my_posts', | |
'permission_callback' => function() { | |
return current_user_can( 'edit_others_posts' ); |
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( 'rest_api_init', 'my_register_route' ); | |
function my_register_route() { | |
register_rest_route( 'my-route', 'my-phrase', array( | |
'methods' => 'GET', | |
'callback' => 'custom_phrase', | |
'permission_callback' => function() { | |
return current_user_can( 'edit_posts' ); | |
}, |
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( 'rest_api_init', 'my_register_route' ); | |
function my_register_route() { | |
register_rest_route( 'my-route', 'my-phrase', array( | |
'methods' => 'GET', | |
'callback' => 'custom_phrase', | |
) | |
); | |
} |
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( 'admin_notices', 'my_error_notice' ); | |
function my_error_notice() { | |
?> | |
<div class="notice notice-error"> | |
<p><?php _e( 'There has been an error.', 'my-text-domain' );?></p> | |
</div> | |
<?php | |
} |
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 | |
if( ! empty( get_option( 'my_update_status' ) ) ) { | |
add_action( 'admin_notices', 'my_update_notice' ); | |
} | |
function my_update_notice() { | |
?> | |
<div class="notice notice-success"> | |
<p><?php _e( 'The update was completed successfully!', 'my-text-domain' ); ?></p> | |
</div> |
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 | |
if( get_option( 'my_dismiss_notice' ) != true ) { | |
add_action( 'admin_notices', 'add_dismissible' ); | |
} | |
function add_dismissible() { | |
?> | |
<div class='notice notice-error my-dismiss-notice is-dismissible'> | |
<p>This is a dismissble notice.</p> | |
</div> |
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( 'admin_enqueue_scripts', 'add_script' ); | |
function add_script() { | |
wp_register_script( 'notice-update', plugins_url() . '/add-notices/js/update-notice.js','','1.0', false ); | |
wp_localize_script( 'notice-update', 'notice_params', array( | |
ajaxurl => get_admin_url() . 'admin-ajax.php', | |
)); | |
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_ajax_my_dismiss_notice', 'my_dismiss_notice' ); | |
function my_dismiss_notice() { | |
update_option( 'my_dismiss_notice', true ); | |
} | |
?> |
NewerOlder