| Server IP : 152.53.162.115 / Your IP : 216.73.217.85 Web Server : Apache/2 System : Linux host 6.12.0-55.40.1.el10_0.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Oct 21 05:54:51 EDT 2025 x86_64 User : pbshosting ( 1005) PHP Version : 8.3.30 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/pbshosting/domains/drsomanathcp.com/private_html/wp-content/plugins/notifications/ |
Upload File : |
<?php
/*Plugin Name: Notifications
Description: Notification Popup
Version: 5.0
Author: Sajin
License: GPLv2
*/
function wptuts_styles_with_the_lot()
{
wp_register_style( 'custom-style', plugins_url( '/style.css', __FILE__ ), array(), '20120208', 'all' );
wp_enqueue_style( 'custom-style' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_styles_with_the_lot' );
function wpse_enqueue_datepicker() {
global $post_type;
if( 'notification' == $post_type )
{
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_register_style( 'jquery-ui', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css' );
wp_enqueue_style( 'jquery-ui' );
}
}
add_action( 'admin_enqueue_scripts', 'wpse_enqueue_datepicker' );
function wptuts_scripts_basic()
{
global $post_type;
if( 'notification' == $post_type )
{
wp_register_script( 'timepicker-script', plugins_url( '/js/jquery.timepicker.js', __FILE__ ) );
wp_enqueue_script( 'timepicker-script' );
wp_register_script( 'custom-script', plugins_url( '/js/custom.js', __FILE__ ) );
wp_enqueue_script( 'custom-script' );
}
}
add_action( 'admin_enqueue_scripts', 'wptuts_scripts_basic' );
// register custom post type to work with
function my_post_type_notificaton() {
$labels = array(
'name' => _x('Notifications', 'post type general name'),
'singular_name' => _x('Notification', 'post type singular name'),
'add_new' => _x('Add New', 'Notification'),
'add_new_item' => __('Add New Notification'),
'edit_item' => __('Edit Notification'),
'new_item' => __('New Notification'),
'view_item' => __('View Notification'),
'search_items' => __('Search Notifications'),
'not_found' => __('No Notifications found'),
'not_found_in_trash' => __('No Notifications found in Trash'),
'parent_item_colon' => __('Post'),
'parent' => __('Post'),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true, //false - to hide from the admin area menu
'rewrite' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => true, //allow parent pages
'show_in_nav_menus' => false,
//'menu_icon' => get_template_directory_uri() . '/images/icons/villa.png',
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail',)
);
register_post_type('notification', $args);
}
add_action('init', 'my_post_type_notificaton');
function my_custom_status_creation(){
register_post_status( 'expire', array(
'label' => _x( 'Expired', 'notification' ),
'label_count' => _n_noop( 'Expired <span class="count">(%s)</span>', 'Expired <span class="count">(%s)</span>'),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true
));
}
add_action( 'init', 'my_custom_status_creation' );
function my_custom_status_add_in_quick_edit() {
echo "<script>
jQuery(document).ready( function() {
jQuery( 'select[name=\"_status\"]' ).append( '<option value=\"expire\">Expired</option>' );
});
</script>";
}
add_action('admin_footer-edit.php','my_custom_status_add_in_quick_edit');
function my_custom_status_add_in_post_page() {
echo "<script>
jQuery(document).ready( function() {
jQuery( 'select[name=\"post_status\"]' ).append( '<option value=\"expire\">Expired</option>' );
});
</script>";
}
add_action('admin_footer-post.php', 'my_custom_status_add_in_post_page');
add_action('admin_footer-post-new.php', 'my_custom_status_add_in_post_page');
function display_status_label( $statuses ) {
global $post;
//Display label on all posts list but not on the custom status list
if( get_query_var( 'post_status' ) != 'expire' ){
if( $post->post_status == 'expire' ){
return array('Expired');
}
}
return $statuses;
}
add_filter( 'display_post_states', 'display_status_label' );
include( plugin_dir_path( __FILE__ ) . 'inc/exp_date_meta.php');
include( plugin_dir_path( __FILE__ ) . 'templates/notification-list.php');
?>