PluginProbe
Tracking Script Manager / 2.0.10
Tracking Script Manager v2.0.10
trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 All 33 releases
tracking-script-manager / templates / script-page-metabox.php

script-page-metabox.php in Tracking Script Manager 2.0.10, at templates/script-page-metabox.php

52 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <p>Use this dropdown to select specific Page(s) or Post(s) where the script should output. If it's left blank, then the script will be global.</p>
2 <select class="r8_tsm_page_select" name="r8_tsm_script_page[]" multiple="multiple"></select>
3
4 <?php
5 $post_types = get_post_types( array( 'public' => true ), 'objects', 'and' );
6 $data = array();
7 foreach ( $post_types as $post_type ) {
8 if ( $post_type->name === 'attachment' ) {
9 continue;
10 }
11
12 $args = array(
13 'post_type' => $post_type->name,
14 'status' => 'publish',
15 'posts_per_page' => -1
16 );
17
18 $posts = get_posts($args);
19
20 if ( count($posts) > 0 ) {
21
22 $children = array();
23
24 foreach ( $posts as $post ) {
25 if ( is_array( $script_page ) && in_array( $post->ID, $script_page ) ) {
26 $children[] = array(
27 'id' => $post->ID,
28 'text' => $post->post_title,
29 'selected' => true
30 );
31 } else {
32 $children[] = array(
33 'id' => $post->ID,
34 'text' => $post->post_title
35 );
36 }
37 }
38
39 $data[] = array(
40 'text' => ucwords($post_type->labels->menu_name),
41 'children' => $children
42 );
43 }
44 }
45
46 $data = json_encode($data);
47 ?>
48
49 <script type="text/javascript">
50 var tsm_data = <?php echo $data; ?>;
51 </script>
52