function cuisine_post_media($pid = null, $posttype = null) { if ($pid == null) { $pid = cuisine_get_post_id(); } if ($posttype == null) { $posttype = get_post_type($pid); } return get_post_meta($pid, $posttype . '_media', true); }
/** * Generate the back url: * * @access public * @return url */ function cuisine_simple_view_back_url() { global $pagenow, $cuisine; if ($pagenow == 'post-new.php') { if (isset($_GET['post_type'])) { return admin_url() . '/edit.php?post_type=' . $_GET['post_type']; } $url = admin_url() . '/edit.php?post_type=post'; } else { if ($pagenow == 'post.php') { $pid = cuisine_get_post_id(); $pt = get_post_type($pid); $url = admin_url() . '/edit.php?post_type=' . $pt; } else { $url = admin_url(); } } return apply_filters('cuisine_simple_view_back_url', $url); }
/** * Add Cuisine's admin scripts. * * @access public * @return void **/ function cuisine_admin_scripts() { global $pagenow, $post, $cuisine; if (isset($_GET['post'])) { wp_localize_script('jquery', 'JSvars', array('post_id' => $_GET['post'], 'post_type' => get_post_type($_GET['post']), 'adminurl' => admin_url(), 'pluginurl' => $cuisine->plugin_url, 'asseturl' => $cuisine->asset_url)); } else { if (isset($_GET['post_type'])) { wp_localize_script('jquery', 'JSvars', array('post_type' => $_GET['post_type'], 'adminurl' => admin_url(), 'pluginurl' => $cuisine->plugin_url, 'asseturl' => $cuisine->asset_url)); } else { wp_localize_script('jquery', 'JSvars', array('adminurl' => admin_url(), 'pluginurl' => $cuisine->plugin_url, 'asseturl' => $cuisine->asset_url)); } } // Add scripts for simple view: if (cuisine_simple_view_is_active()) { if ($pagenow == 'media-upload.php' && isset($_GET['cuisine_media'])) { //check for the media library wp_enqueue_style('cuisine_media_style', $cuisine->asset_url . '/css/admin-media.css'); wp_enqueue_script('cuisine_media_script', $cuisine->asset_url . '/js/admin-media.js'); } } // Load the media scripts and styles on the widgets page: if ($pagenow == 'widgets.php') { wp_enqueue_style('thickbox'); wp_enqueue_media(); //add the scripts for the general admin area: wp_enqueue_script('cuisine_main_class', $cuisine->asset_url . '/js/cuisine.js', array('jquery', 'jquery-ui-sortable', 'thickbox'), false, true); } else { if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'page.php' || $pagenow == 'page-new.php') { //if this post doesn't support featured images, include the media: $pid = cuisine_get_post_id(); if ($pid && !post_type_supports(get_post_type($pid), 'thumbnail')) { wp_enqueue_media(); } wp_enqueue_script('cuisine_specials_class', $cuisine->asset_url . '/js/cuisine-specials.js', array('jquery', 'jquery-ui-sortable', 'thickbox'), false, true); //add the scripts for the general admin area: wp_enqueue_script('cuisine_main_class', $cuisine->asset_url . '/js/cuisine.js', array('jquery', 'jquery-ui-sortable', 'thickbox'), false, true); } } //add the general admin styles & scripts wp_enqueue_style('cuisine_admin', $cuisine->asset_url . '/css/admin.css'); wp_enqueue_script('cuisine_admin', $cuisine->asset_url . '/js/admin.js', array('jquery', 'jquery-ui-sortable', 'thickbox'), false, true); //little security-measure: //stop WordPress from displaying the theme editor: remove_action('admin_menu', '_add_themes_utility_last', 101); }
/** * Add the html for the metabox: */ function cuisine_widget_home_text_meta_html() { $pid = cuisine_get_post_id(); $home_text = get_post_meta($pid, 'home_text_widget', true); //add the nonce: cuisine_get_nonce(); ?> <label class="cuisine_label clearfix">Titel: <input type="text" value="<?php echo $home_text['home_text_title']; ?> " name="home_text_title" class="cuisine_input" /></label> <label class="cuisine_label clearfix">Body:</label> <textarea id="home_text_body" name="home_text_body" style="width:100%;height:150px;"><?php echo $home_text['home_text_body']; ?> </textarea> <?php }
/** * Add the html for the metabox: */ function cuisine_widget_home_image_meta_html() { $pid = cuisine_get_post_id(); $home_images = get_post_meta($pid, 'home_widget_images', true); $i = 0; //add the nonce: cuisine_get_nonce(); foreach ($home_images as $img) { $wid = $img['image_widget_id']; $arrpos = 'home_image_widget_array[' . $i . ']'; ?> <div class="cuisine_home_image_widget"> <label class="cuisine_label"><p>Titel</p><input type="text" value="<?php echo $img['title']; ?> " name="<?php echo $arrpos; ?> [title]"/></label> <p class="cuisine_widget_centralized"> <div id="imagecontainer-<?php echo $wid; ?> " class="cuisine_widget_centralized"> <?php if ($img['url'] != '#') { ?> <img src="<?php echo $img['url']; ?> " id="image-<?php echo $wid; ?> " class="cuisine_widget_image"/> <?php } ?> </div> </p> <p class="cuisine_widget_centralized"> <a href="#" class="button-primary cuisine-widget-media" data-widget="<?php echo $wid; ?> " style="text-decoration:none"><?php echo __('Afbeelding kiezen'); ?> </a> </p> <label class="cuisine_label"><p>Link</p><input type="text" value="<?php echo $img['link']; ?> " name="<?php echo $arrpos; ?> [link]"/></label> <input type="hidden" name="<?php echo $arrpos; ?> [link_target]" value="<?php echo $img['link_target']; ?> "/> <input type="hidden" id="imageurl-<?php echo $wid; ?> " name="<?php echo $arrpos; ?> [url]" value="<?php echo $img['url']; ?> " /> <input type="hidden" id="imageid-<?php echo $wid; ?> " name="<?php echo $arrpos; ?> [image_id]" value="<?php echo $img['image_id']; ?> " /> <input type="hidden" name="<?php echo $arrpos; ?> [image_widget_id]" value="<?php echo $wid; ?> " /> </div> <?php $i++; } echo '<div class="clearfix"></div>'; }