function toolset_assigned_message($kind, $slug = null)
{
    global $post;
    switch ($kind) {
        case "content-template":
            if (function_exists('is_wpv_content_template_assigned')) {
                if (!is_wpv_content_template_assigned() && !preg_match('/\\[wpv\\-(view|post\\-body)/', get_the_content()) && current_user_can('manage_options')) {
                    ?>
					<div class="panel panel-default not-assigned collapse in">
						<div class="panel-heading">
							<?php 
                    _e('There is no Content Template assigned', "toolset_starter");
                    ?>
							<a href="#" data-toggle="collapse" data-target=".not-assigned" class="alignright small">
								<i class="fa fa-close"></i> <?php 
                    _e("Dismiss", "toolset_starter");
                    ?>
							</a>
						</div>
						<div class="panel-body">
							<div class="not-assigned-body">
								<h4><?php 
                    _e("Do you want this page to look different?", "toolset_starter");
                    ?>
 </h4>
								<a class="btn btn-lg btn-primary"
								   href="<?php 
                    echo admin_url('admin.php?page=view-templates');
                    ?>
"
								   title="<?php 
                    _e("Content Templates", "toolset_starter");
                    ?>
">
									<?php 
                    _e("Assign a Content Template", "toolset_starter");
                    ?>
								</a>
							</div>
							<div class="not-assigned-helper">

								<a href="http://wp-types.com/documentation/user-guides/view-templates/" target="_blank"
								   title="<?php 
                    _e("Designing WordPress Content with Content Templates", "toolset_starter");
                    ?>
">
									<?php 
                    _e('Learn about Content Templates', "toolset_starter");
                    ?>
								</a>

							</div>
						</div>
						<div class="panel-footer panel-footer-sm text-center">
							<?php 
                    _e("You can see this message because you are logged in as a user who can assign Content Templates. <br>Your visitors won't see this message.", "toolset_starter");
                    ?>
						</div>
					</div>
				<?php 
                }
            }
            break;
        case "views-archive":
            if (function_exists('is_wpv_wp_archive_assigned')) {
                if (!is_wpv_wp_archive_assigned() && current_user_can('manage_options')) {
                    ?>
					<div class="panel panel-default not-assigned collapse in">
						<div class="panel-heading">
							<?php 
                    _e('There is no WordPress Archive Template assigned', "toolset_starter");
                    ?>
							<a href="#" data-toggle="collapse" data-target=".not-assigned" class="alignright small">
								<i class="fa fa-close"></i> <?php 
                    _e("Dismiss", "toolset_starter");
                    ?>
							</a>
						</div>
						<div class="panel-body">
							<div class="not-assigned-body">
								<h4><?php 
                    _e("Do you want this page to look different?", "toolset_starter");
                    ?>
 </h4>
								<a class="btn btn-lg btn-primary"
								   href="<?php 
                    echo admin_url('admin.php?page=view-archives');
                    ?>
"
								   title="<?php 
                    _e("WordPress Archive", "toolset_starter");
                    ?>
">
									<?php 
                    _e("Assign a WordPress Archive Template", "toolset_starter");
                    ?>
								</a>
							</div>
							<div class="not-assigned-helper">
								<a href="http://wp-types.com/documentation/user-guides/normal-vs-archive-views/"
								   target="_blank"
								   title="<?php 
                    _e("Customize Archive Page with WordPress Archive Template", "toolset_starter");
                    ?>
">
									<?php 
                    _e('Learn about WordPress Archive Templates', "toolset_starter");
                    ?>
								</a>
							</div>
						</div>
						<div class="panel-footer panel-footer-sm text-center">
							<?php 
                    _e("You can see this message because you are logged in as a user who can assign WordPress Archive Templates. <br>Your visitors won't see this message.", "toolset_starter");
                    ?>
						</div>
					</div>
				<?php 
                }
                //if user can
            }
            break;
        case preg_match('/layout-*/', $kind) ? true : false:
            if (function_exists('user_can_assign_layouts')) {
                if (!is_ddlayout_assigned() && user_can_assign_layouts() && !ddl_layout_slug_exists($slug)) {
                    switch ($kind) {
                        case "layout-page":
                            $header = __('Page: There is no Layout assigned', "toolset_starter");
                            $learn_link = "http://wp-types.com/documentation/user-guides/designing-pages-archive-templates-using-views-plugin#layouts-as-templates-for-content";
                            $learn_anchor = __("Using Layouts as Templates for Contents", "toolset_starter");
                            break;
                        case "layout-post":
                            $header = __('Single Post: There is no Layout assigned', "toolset_starter");
                            $learn_link = "http://wp-types.com/documentation/user-guides/designing-pages-archive-templates-using-views-plugin#layouts-as-templates-for-content";
                            $learn_anchor = __("Using Layouts as Templates for Contents", "toolset_starter");
                            break;
                        case "layout-archive":
                            $header = __('Archive Page: There is no Layout assigned', "toolset_starter");
                            $learn_link = "http://wp-types.com/documentation/user-guides/designing-pages-archive-templates-using-views-plugin#layouts-for-archives";
                            $learn_anchor = __("Using Layouts as Templates for Archives", "toolset_starter");
                            break;
                        case "layout-404":
                            $header = __('Error 404 Page: There is no Layout assigned', "toolset_starter");
                            $learn_link = "http://wp-types.com/documentation/user-guides/designing-custom-404-error-pages-with-layouts/";
                            $learn_anchor = __("Designing the 404 Page with Layouts", "toolset_starter");
                            break;
                    }
                    ?>
					<div class="panel panel-default not-assigned ">
						<div class="panel-heading">
							<?php 
                    echo $header;
                    ?>

						</div>
						<div class="panel-body">
							<div class="not-assigned-body">

								<h4><?php 
                    _e("Do you want this page to look different?", "toolset_starter");
                    ?>
 </h4>
								<a class="btn btn-lg btn-primary"
								   href="<?php 
                    echo admin_url('admin.php?page=dd_layouts');
                    ?>
"
								   title="<?php 
                    _e("Layouts", "toolset_starter");
                    ?>
"><?php 
                    _e("Assign a Layout", "toolset_starter");
                    ?>
								</a>
							</div>
							<div class="not-assigned-helper">

								<p><?php 
                    _e("Find out more:", "toolset_starter");
                    ?>
</p>
								<ul>
									<li>
										<a href="<?php 
                    echo $learn_link;
                    ?>
"
										   target="_blank"
										   title="<?php 
                    echo $learn_anchor;
                    ?>
">
											<?php 
                    echo $learn_anchor;
                    ?>
										</a>
									</li>
									<li>
										<a href="http://wp-types.com/documentation/user-guides/develop-layouts-based-themes/#how-layout-plugins-works"
										   target="_blank"
										   title="<?php 
                    _e("Learn how the Layouts plugin works", "toolset_starter");
                    ?>
">
											<?php 
                    _e('Learn how the Layouts plugin works', "toolset_starter");
                    ?>
										</a>
									</li>
									<li>
										<a href="http://discover-wp.com/site-types/toolset-classifieds-layouts/"
										   target="_blank"
										   title="<?php 
                    _e("Try our reference site built with this theme", "toolset_starter");
                    ?>
">
											<?php 
                    _e('Try our reference site built with this theme', "toolset_starter");
                    ?>
										</a>
									</li>
								</ul>
							</div>
						</div>
						<div class="panel-footer panel-footer-sm text-center">
							<?php 
                    _e("You can see this message because you are logged in as a user who can assign Layouts. <br>Your visitors won't see this message.", "toolset_starter");
                    ?>
						</div>
					</div>
				<?php 
                }
                //if user can
            }
            //function exists
            break;
    }
}
 public function set_layouts_post_types_on_usage_change()
 {
     if (user_can_assign_layouts() === false) {
         die(WPDD_Utils::ajax_caps_fail(__METHOD__));
     }
     if ($_POST && wp_verify_nonce($_POST['layout-set-change-post-types-nonce'], 'layout-set-change-post-types-nonce')) {
         $post_types = isset($_POST[self::POST_TYPES_OPTION_NAME]) && is_array($_POST[self::POST_TYPES_OPTION_NAME]) ? array_unique($_POST[self::POST_TYPES_OPTION_NAME]) : array();
         if (isset($_POST['extras'])) {
             $extras = $_POST['extras'];
             if (isset($extras['post_types']) && count($extras['post_types']) > 0) {
                 $types_to_batch = $extras['post_types'];
             }
         }
         if (isset($extras) && isset($types_to_batch)) {
             $send = wp_json_encode(array('message' => array('changed' => $this->handle_set_option_and_bulk_at_once($_POST['layout_id'], $post_types, null), 'done' => 'yes')));
         } else {
             $send = wp_json_encode(array('message' => array('changed' => $this->handle_post_type_data_save($_POST['layout_id'], $post_types, true), 'done' => 'yes')));
         }
     } else {
         $send = wp_json_encode(array('error' => __(sprintf('Nonce problem: apparently we do not know where the request comes from. %s', __METHOD__), 'ddl-layouts')));
     }
     die($send);
 }
 public function listing_scripts()
 {
     global $wpddlayout;
     //speed up ajax calls sensibly
     wp_deregister_script('heartbeat');
     wp_register_script('heartbeat', false);
     $localization_array = array('res_path' => WPDDL_RES_RELPATH, 'listing_lib_path' => WPDDL_GUI_RELPATH . "/listing/js/", 'editor_lib_path' => WPDDL_GUI_RELPATH . "editor/js/", 'common_rel_path' => WPDDL_TOOLSET_COMMON_RELPATH, 'ddl_listing_nonce' => wp_create_nonce('ddl_listing_nonce'), 'ddl_listing_show_posts_nonce' => wp_create_nonce('ddl_listing_show_posts_nonce'), 'ddl_listing_status' => isset($_GET['status']) && $_GET['status'] === 'trash' ? $_GET['status'] : 'publish', 'lib_path' => WPDDL_RES_RELPATH . '/js/external_libraries/', 'strings' => $this->get_listing_js_strings(), 'is_listing_page' => true, 'user_can_delete' => user_can_delete_layouts(), 'user_can_assign' => user_can_assign_layouts(), 'user_can_edit' => user_can_edit_layouts(), 'user_can_create' => user_can_create_layouts());
     $wpddlayout->enqueue_scripts(array('dd-listing-page-main', 'ddl-post-types'));
     $wpddlayout->localize_script('dd-listing-page-main', 'DDLayout_settings', array('DDL_JS' => $localization_array, 'DDL_OPN' => self::change_layout_dialog_options_name(), 'items_per_page' => DDL_ITEMS_PER_PAGE));
     $wpddlayout->enqueue_styles(array('views-pagination-style', 'dd-listing-page-style'));
 }
 public function view_layout_from_editor_callback()
 {
     global $wpddlayout;
     if (user_can_assign_layouts() === false) {
         die(WPDD_Utils::ajax_caps_fail(__METHOD__));
     }
     if ($_POST && wp_verify_nonce($_POST['ddl-view-layout-nonce'], 'ddl-view-layout-nonce')) {
         $layout = WPDD_Layouts::get_layout_settings($_POST['layout_id'], true);
         if ($layout && isset($layout->has_child) && ($layout->has_child === 'true' || $layout->has_child === true)) {
             $send = wp_json_encode(array('message' => __("This layout contains a child layout and can't be viewed directly.", 'ddl-layouts') . '<br />' . __("You'll need to switch to one of the child layouts and view it.", 'ddl-layouts')));
         } else {
             $items = $this->get_where_used_x_amount_of_posts($_POST['layout_id'], false, 3);
             $posts = $items->posts;
             $layout_post_types = $wpddlayout->post_types_manager->get_layout_post_types($_POST['layout_id']);
             $loops = $wpddlayout->layout_post_loop_cell_manager->get_layout_loops($_POST['layout_id']);
             if (count($posts) === 0 && count($loops) === 0 && count($layout_post_types) === 0) {
                 $send = wp_json_encode(array('message' => __(sprintf("This layout is not assigned to any content. %sFirst, assign it to content and then you can view it on the site's front-end. %sYou can assign this layout to content at the bottom of the layout editor.", '<br>', '<br>'), 'ddl-layouts')));
             } else {
                 $items = array();
                 foreach ($layout_post_types as $post_type) {
                     $push = $this->get_x_posts_of_type($post_type, $_POST['layout_id'], 1);
                     if (is_array($push)) {
                         $posts = array_merge($posts, $push);
                     }
                 }
                 foreach ($posts as $post) {
                     $post_types = $wpddlayout->post_types_manager->get_post_types_from_wp();
                     $label = $post_types[$post->post_type]->labels->singular_name;
                     $labels = $post_types[$post->post_type]->labels->name;
                     $item = array('href' => get_permalink($post->ID), 'title' => $post->post_title, 'type' => $label, 'types' => $labels);
                     if (in_array($item, $items) === false) {
                         $items[] = $item;
                     }
                 }
                 foreach ($loops as $loop) {
                     $push = $wpddlayout->layout_post_loop_cell_manager->get_loop_display_object($loop);
                     if (null !== $push) {
                         array_push($items, $push);
                     }
                 }
                 $send = wp_json_encode(array('Data' => $items, 'message' => __(sprintf("This layout is not assigned to any content. %sFirst, assign it to content and then you can view it on the site's front-end. %sYou can assign this layout to content at the bottom of the layout editor.", '<br>', '<br>'), 'ddl-layouts'), 'no_preview_message' => __('No previews available', 'ddl-layouts')));
             }
         }
     } else {
         $send = wp_json_encode(array('error' => __(sprintf('Nonce problem: apparently we do not know where the request comes from. %s', __METHOD__), 'ddl-layouts')));
     }
     die($send);
 }