name,$notinarray))
{
if(!get_option($post_type_alt->name.'_metaalert'))
{
update_option($post_type_alt->name.'_metaalert', 'empty');
}
}
}
}
//ADD Script into admin side
function alt_admin_js() //enque script
{
wp_enqueue_script( 'admin_alert_js', plugin_dir_url( __FILE__ ) . 'js/admin_js.js' );
}
add_action('admin_enqueue_scripts', 'alt_admin_js');
//hook to add code in wp head and chek if post is selected or not
add_action('wp_head', 'alt_checkposttype_alert_front');
function alt_checkposttype_alert_front()
{
$post_type_alt = get_post_type( get_the_id() );
$meta_value = get_option($post_type_alt.'_metaalert');
if(count($meta_value)==1)
{
//echo '
';
//var_dump($meta_value);
//$meta_value[]='';
}
if(!empty($meta_value))
{
//echo count($meta_value);
if($meta_value != 'empty')
{
if(in_array(get_the_id(),$meta_value))
{
wp_register_script( 'alert_messages_js', plugin_dir_url( __FILE__ ) . 'js/alt_myscript.js' );
// Localize the script with new data
$translation_array = array(
'alt_val_msg' => __( get_option('alert_text'), 'alertbox' ),
'a_value' => 'first'
);
wp_localize_script( 'alert_messages_js', 'alt_object_js', $translation_array );
// Enqueued script with localized data.
wp_enqueue_script( 'alert_messages_js' );
}
}
}
}
//core clas for chek post type and display list and save data
class AlertPosttypeSelect
{
function alt_list_posttype()
{
$alt_types = get_post_types();
$alt_post_types = get_post_types($args,'name','or');
$posttypes_array = array();
$notinarray = array ('attachment','revision','nav_menu_item','custom_css','customize_changeset','wpcf7_contact_form','acf-field-group','acf-field','mc4wp-form');
foreach ($alt_post_types as $post_type_alt )
{
if(isset($_POST[$post_type_alt->name]))
{
if($_POST[$post_type_alt->name] == 'on')
{
$this->alt_save_alert_data($post_type_alt->name);
}
}else
{
if(isset($_POST['submit']))
{
if($_POST[$post_type_alt->name] != 'on')
{
$this->alt_remove_all_field($post_type_alt->name);
}
}
}
if(!in_array($post_type_alt->name,$notinarray))
{
?>