function test_pmp_json_obj() { $pmp_obj = pmp_json_obj(array('test_key' => 'test value')); $this->assertEquals($pmp_obj['test_key'], 'test value'); $this->assertTrue(!empty($pmp_obj['creators'])); $this->assertTrue(!empty($pmp_obj['ajax_nonce'])); }
/** * Print distributor meta box for distributor * * @since 0.0.1 */ function pmp_distributor_options_meta_box_for_distributor() { global $post; wp_nonce_field('pmp_dist_meta_box', 'pmp_dist_meta_box_nonce'); ?> <div id="pmp-dist-options" class="async-menu-container"> <p>Set a Series and Property for this post.</p> <?php foreach (array('series', 'property') as $type) { ?> <div id="pmp-<?php echo $type; ?> -for-post" class="async-menu-option pmp-dist-option-for-post" data-pmp-dist-option-type="<?php echo $type; ?> "> <span class="spinner"></span> </div> <?php } ?> </div> <div id="pmp-publish-actions"> <?php submit_button('Update dist. options', 'primary', 'pmp_save_dist_options', false, $attrs); ?> </div> <?php /* * Javascript required for the async select menus for Groups, Series, Property */ ?> <script type="text/javascript"> var PMP = <?php echo json_encode(pmp_json_obj(array('post_id' => $post->ID))); ?> ; </script><?php pmp_async_select_template(); }
/** * The PMP meta box to end all PMP meta boxes. * * @since 0.3 */ function pmp_mega_meta_box($post) { wp_nonce_field('pmp_mega_meta_box', 'pmp_mega_meta_box_nonce'); $pmp_guid = get_post_meta($post->ID, 'pmp_guid', true); pmp_last_modified_meta($post); if (!empty($pmp_guid) && !pmp_post_is_mine($post->ID)) { pmp_subscribe_to_updates_markup($post); } else { /* * Container elements for async select menus for Groups, Series and Property for the post */ if ($post->post_status == 'publish') { ?> <div id="pmp-override-defaults"> <p>Modify the Group, Series and Property settings for this post.</p> <?php foreach (array('group', 'series', 'property') as $type) { ?> <div id="pmp-<?php echo $type; ?> -select-for-post" class="pmp-select-for-post"> <span class="spinner"></span> </div> <?php } ?> </div><?php } pmp_publish_and_push_to_pmp_button($post); /* * Javascript required for the async select menus for Groups, Series, Property */ ?> <script type="text/javascript"> var PMP = <?php echo json_encode(pmp_json_obj(array('post_id' => $post->ID))); ?> ; </script><?php pmp_async_select_template(); } }
/** * Render the plugin's series and properties pages * * @since 0.2 */ function pmp_collections_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if ($_GET['page'] == 'pmp-properties-menu') { $name = 'Properties'; $profile = 'property'; } else { if ($_GET['page'] == 'pmp-series-menu') { $name = 'Series'; $profile = 'series'; } } if (isset($_POST['pmp-unset-default-' . $profile])) { delete_option('pmp_default_' . $profile); } $sdk = new SDKWrapper(); $pmp_collection = $sdk->query2json('queryDocs', array('profile' => $profile, 'writeable' => 'true', 'limit' => 9999)); $context = array('PMP' => pmp_json_obj(array('default_collection' => get_option('pmp_default_' . $profile, false), 'pmp_collection' => $pmp_collection, 'profile' => $profile, 'name' => $name)), 'name' => $name, 'profile' => $profile); pmp_render_template('collections.php', $context); }