-1,'post_type' => 'adlock-widget');
$pages = get_posts($args);
foreach ($pages as $page){
$pageid = $page->ID;
$thesnippet = get_post_meta($pageid, 'am_codesnippet', true);
$pagelist = get_post_meta($pageid, 'am_active_pages', true);
$subidinput = get_post_meta($pageid, 'am_sub_id_input', true);
$idlist = explode(',', $pagelist);
$currentpageid = get_the_ID();
$thetitle = get_the_title();
$scrubbedtitle = am_cleanse_title($thetitle);
$scrubbedsubidinput = am_cleanse_title($subidinput);
if(is_page($currentpageid)||is_single($currentpageid)){
foreach($idlist as $dapageid){
if($currentpageid == $dapageid){
if($subidinput){
$subidsnippet = str_replace('&sid=', '&sid=' . $scrubbedsubidinput, $thesnippet);
echo $subidsnippet;
}
else {
$subidsnippet = str_replace('&sid=', '&sid=' . $currentpageid . '-' . $scrubbedtitle, $thesnippet);
echo $subidsnippet;
}
}
}
}
}
}
function am_init_register_post_type() {
register_post_type( 'adlock-widget' ,
array(
'labels' =>array(
'name' => __('AdLock® Widgets', 'adlock-widget'),
'singular_name' => __('AdLock® Widget', 'adlock-widget'),
'add_new' => __('Add New', 'adlock-widget'),
'add_new_item' => __('Add New AdLock® Widget', 'adlock-widget'),
'edit' => __('Edit', 'adlock-widget'),
'edit_item' => __('Edit AdLock® Widget', 'adlock-widget'),
'new_item' => __('New AdLock® Widget', 'adlock-widget'),
'view' => __('View AdLock® Widget', 'adlock-widget'),
'view_item' => __('View AdLock® Widget', 'adlock-widget'),
'search_items' => __('Search AdLock® Widget', 'adlock-widget'),
'not_found' => __('No Menu Items Found', 'adlock-widget'),
'not_found_in_trash' => __('No Menu Items found in the trash', 'adlock-widget')
),
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
'capabilities' => array(
'edit_post' => 'update_core',
'read_post' => 'update_core',
'delete_post' => 'update_core',
'edit_posts' => 'update_core',
'edit_others_posts' => 'update_core',
'publish_posts' => 'update_core',
'read_private_posts' => 'update_core'
),
'hierarchical' => false,
'menu_position' => 10,
'menu_icon' => 'dashicons-slides',
'can_export' => true,
'has_archive' => false,
'supports' => array('title','custom-fields')
)
);
}
function add_widget_metaboxes() {
add_meta_box('am_widget_profile', 'You must have an Adscend Media publisher account in order to use this plugin. If you do not yet have one, Apply Here.', 'am_load_widget_profile', 'adlock-widget', 'normal', 'high');
}
function am_load_widget_profile() {
global $post;
$markup = '';
// Noncename needed to verify where the data originated
$markup .= '';
// Get the meta data if its already been entered
$codesnippet = get_post_meta($post->ID, 'am_codesnippet', true);
$subid = get_post_meta($post->ID, 'am_sub_id_input', true);
$activepages = get_post_meta($post->ID, 'am_active_pages', true);
// Echo out the field
$markup .= '
Post types included: '; $firstcheck = false; foreach ( $post_types as $post_type ) { if($firstcheck === true){ $checklistcode .= ', '; } $checklistcode .= $post_type; $firstcheck = true; } $checklistcode .= '
'; $checklistcode .= ''; $args = array( 'numberposts' => -1, 'post_type' => $post_types); $posts = get_posts($args); $checklistcode .= '