Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //-------------------------------------------------------------------
- // Modifies the default method for injecting media into posts
- //-------------------------------------------------------------------
- //-----------------------------------
- class ewmInsertMedia {
- //-----------------------------------
- //----------------------------
- function ewmInsertMedia () {
- //----------------------------
- add_filter('media_send_to_editor',
- array($this,
- modifyMediaInsert) , 10, 3);
- }
- //----------------------------
- function modifyMediaInsert(
- $html, $send_id, $attachment) {
- //----------------------------
- $output = '[flash '.$attachment['url'].']';
- return $output;
- }
- }
- //instantiate the class
- $ewmIM = new ewmInsertMedia();
- ?>
- <?php
- //-------------------------------------------------------------------
- //-------------------------------------------------------------------
- //----------------------------------
- // Add to admin_menu action
- //----------------------------------
- $my_page = add_media_page('Shiba Gallery', 'Shiba Gallery',
- 'administrator', 'shiba_gallery', 'my_plugin_page' );
- add_action("admin_print_scripts-{$my_page}",
- 'my_plugin_page_scripts');
- add_action("admin_print_styles-{$my_page}",
- 'my_plugin_page_styles');
- //-----------------------------------
- function my_plugin_page_styles() {
- //-----------------------------------
- wp_enqueue_style('thickbox');
- }
- //-----------------------------------
- function my_plugin_page_scripts() {
- //-----------------------------------
- wp_enqueue_script('thickbox');
- }
- //-----------------------------------
- $image_library_url = get_upload_iframe_src( 'image', null, 'library' );
- $image_library_url = remove_query_arg( array('TB_iframe'), $image_library_url );
- $image_library_url = add_query_arg(
- array( 'context' =>
- 'shiba-gallery-default-image',
- 'TB_iframe' => 1 ),
- $image_library_url );
- ?>
- <p>
- <a title="Set default image" href="<?php
- echo esc_url( $image_library_url ); ?>" id="set-default-image"
- class="button thickbox">Set Default Image</a>
- </p>
- <?php
- //---------------------------------------------
- add_filter('media_upload_tabs',
- 'my_plugin_image_tabs', 10, 1);
- //---------------------------------------------
- function my_plugin_image_tabs(
- $_default_tabs) {
- //---------------------------------------------
- unset($_default_tabs['type']);
- unset($_default_tabs['type_url']);
- unset($_default_tabs['gallery']);
- return($_default_tabs);
- }
- //---------------------------------------------
- add_filter('attachment_fields_to_edit',
- 'my_plugin_action_button', 20, 2);
- //---------------------------------------------
- add_filter('media_send_to_editor',
- 'my_plugin_image_selected', 10, 3);
- //---------------------------------------------
- function my_plugin_action_button(
- $form_fields, $post) {
- //---------------------------------------------
- $send = "<input type='submit' class='button' name='send[$post->ID]'
- value='" . esc_attr__( 'Use as Default' ) . "' />";
- $form_fields['buttons'] = array('tr' =>
- "\t\t<tr class='submit'><td>
- </td><td class='savesend'>$send</td></tr>\n");
- $form_fields['context'] = array( 'input' => 'hidden',
- 'value' => 'shiba-gallery-default-image' );
- return $form_fields;
- }
- //---------------------------------------------
- function my_plugin_image_selected(
- $html, $send_id, $attachment) {
- //---------------------------------------------
- ?>
- <script type="text/javascript">
- /* <![CDATA[ */
- var win = window.dialogArguments || opener || parent || top;
- win.jQuery( '#default_image' ).val('<?php echo $send_id;?>');
- //-----------------------submit the form
- win.jQuery( '#shiba-gallery_options' ).submit();
- /* ]]> */
- </script>
- <?php
- exit();
- }
- //-------------------------------------------------------------------
- //-------------------------------------------------------------------
- //---------------------------------------------
- // Add to admin_menu
- //---------------------------------------------
- if (check_upload_image_context(
- 'shiba-gallery-default-image')) {
- add_filter('media_upload_tabs',
- 'my_plugin_image_tabs', 10, 1);
- add_filter('attachment_fields_to_edit',
- 'my_plugin_action_button', 20, 2);
- add_filter('media_send_to_editor',
- 'my_plugin_image_selected', 10, 3);
- }
- //---------------------------------------------
- function add_my_context_to_url($url, $type) {
- //---------------------------------------------
- if ($type != 'image') return $url;
- if (isset($_REQUEST['context'])) {
- $url = add_query_arg('context', $_REQUEST['context'], $url);
- }
- return $url;
- }
- //---------------------------------------------
- function check_upload_image_context($context) {
- //---------------------------------------------
- if (isset($_REQUEST['context']) && $_REQUEST['context'] == $context) {
- add_filter('media_upload_form_url',
- array($this,
- 'add_my_context_to_url'), 10, 2);
- return TRUE;
- }
- return FALSE;
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // Creating custom fields for attachment
- //-------------------------------------------------------------------
- //---------------------------------------------
- // system hooks
- //---------------------------------------------
- function get_attachment_fields_to_edit(
- $post, $errors = null) {
- // ...
- $form_fields = apply_filters("attachment_fields_to_edit", $form_fields, $post);
- // ...
- }
- //---------------------------------------------
- function media_upload_form_handler() {
- // ...
- $post = apply_filters("attachment_fields_to_save", $post, $attachment);
- // ...
- }
- //---------------------------------------------
- //---------------------------------------------
- add_filter("attachment_fields_to_edit",
- "my_image_attachment_fields_to_edit", null, 2);
- /**----------------------------------------------------
- * Adding our custom fields to the $form_fields array
- *
- * @param array $form_fields
- * @param object $post
- * @return array
- -----------------------------------------------------*/
- function my_image_attachment_fields_to_edit(
- $form_fields, $post) {
- //----------------------------------------------------
- // $form_fields is a special array of fields
- // to include in the attachment form
- // $post is the attachment record in the database
- // $post->post_type == 'attachment'
- // (attachments are treated as posts in WordPress)
- // add our custom field to the $form_fields array
- // input type="text"
- // name/id="attachments[$attachment->ID][custom1]"
- //----------------------------------------------------
- $form_fields["custom1"] = array(
- "label" => __("Custom Text Field"),
- "input" => "text", // this is default if "input" is omitted
- "value" => get_post_meta($post->ID, "_custom1", true)
- );
- //-------------------------------------------------------------
- // if you will be adding error messages for your field,
- // then in order to not overwrite them, as they are pre-attached
- // to this array, you would need to set the field up like this:
- //-------------------------------------------------------------
- $form_fields["custom1"]["label"] = __("Custom Text Field");
- $form_fields["custom1"]["input"] = "text";
- $form_fields["custom1"]["value"] = get_post_meta($post->ID, "_custom1", true);
- return $form_fields;
- }
- //--------------------------------------------
- // text input
- //--------------------------------------------
- $form_fields["custom1"]["label"] = __("Custom Text Field");
- $form_fields["custom1"]["input"] = "text"; // this is default if "input" is omitted
- $form_fields["custom1"]["value"] = get_post_meta($post->ID, "_custom1", true);
- //--------------------------------------------
- // text area
- //--------------------------------------------
- $form_fields["custom2"]["label"] = __("Custom Textarea");
- $form_fields["custom2"]["input"] = "textarea";
- $form_fields["custom2"]["value"] = get_post_meta($post->ID, "_custom2", true);
- //--------------------------------------------
- // hidden field
- //--------------------------------------------
- $form_fields["custom3"]["input"] = "hidden";
- $form_fields["custom3"]["value"] = get_post_meta($post->ID, "_custom3", true);
- //--------------------------------------------
- // select
- //--------------------------------------------
- $form_fields["custom4"]["label"] = __("Custom Select");
- $form_fields["custom4"]["input"] = "html";
- $form_fields["custom4"]["html"] = "
- <select name='attachments[{$post->ID}][custom4]' id='attachments[{$post->ID}][custom4]'>
- <option value='1'>Option 1</option>
- <option value='2'>Option 2</option>
- <option value='3'>Option 3</option>
- </select>";
- //--------------------------------------------
- // checkbox
- //--------------------------------------------
- $form_fields["custom5"]["label"] = __("Custom Checkbox");
- $form_fields["custom5"]["input"] = "html";
- $form_fields["custom5"]["html"] = "the html output goes here, like a checkbox:
- <input type='checkbox' value='1'
- name='attachments[{$post->ID}][custom5]'
- id='attachments[{$post->ID}][custom5]' />";
- //--------------------------------------------
- // helps attribute
- //--------------------------------------------
- $form_fields["custom6"]["label"] = __("Custom Field with Helpful Text");
- $form_fields["custom6"]["value"] = get_post_meta($post->ID, "_custom6", true);
- $form_fields["custom6"]["helps"] = "Put helpful text here.";
- //--------------------------------------------
- // required attribute
- //--------------------------------------------
- $form_fields["custom7"]["label"] = __("Required Field");
- $form_fields["custom7"]["value"] = get_post_meta($post->ID, "_custom7", true);
- $form_fields["custom7"]["required"] = TRUE; // default is FALSE
- //--------------------------------------------
- // extra rows attribute
- //--------------------------------------------
- // extra_rows markup:
- // <tr>
- // <td></td>
- // <td class="{arrayItemKey}">{arrayItemValue}</td>
- // </tr>
- $form_fields["custom8"]["label"] = __("Custom Field with Extra Rows");
- $form_fields["custom8"]["value"] = get_post_meta($post->ID, "_custom8", true);
- // extra_rows must be an associative array $cssClass => $content
- $form_fields["custom8"]["extra_rows"] = array(
- "cssClass1" => "If you need a few rows after your field...",
- "cssClass2" => "...to maybe explain something or add some imagery?
- <img src='".get_bloginfo("wpurl")."/wp-admin/images/align-left.png' />
- <img src='".get_bloginfo("wpurl")."/wp-admin/images/align-center.png' />
- <img src='".get_bloginfo("wpurl")."/wp-admin/images/align-right.png' />",
- );
- //--------------------------------------------
- // tr attribute
- //--------------------------------------------
- $form_fields["custom8"]["tr"] = "
- <tr id='MySpecialRow'>
- <td colspan='2' style='background:#000;color:#fff;'>
- Can do whatever you want, style it, add some fields, display a table of data...sky's the limit
- </td>
- </tr>";
- /**----------------------------------------------------------------
- * @param array $post
- * @param array $attachment
- * @return array
- -----------------------------------------------------------------*/
- function my_image_attachment_fields_to_save(
- $post, $attachment) {
- //------------------------------------------------------------------
- //--------------------------------------------------------------
- // $attachment part of the form $_POST
- // ($_POST[attachments][postID])
- // $post attachments wp post array - will be saved after returned
- // $post['post_type'] == 'attachment'
- //--------------------------------------------------------------
- if( isset($attachment['my_field']) ){
- update_post_meta($post['ID'], '_my_field', $attachment['my_field']);
- }
- return $post;
- }
- //----------------------------------------------------------
- function my_image_attachment_fields_to_save(
- $post, $attachment) {
- //----------------------------------------------------------
- if( isset($attachment['my_field']) ){
- if( trim($attachment['my_field']) == '' ){
- //------------------------------
- // adding our custom error
- //------------------------------
- $post['errors']['my_field']['errors'][] = __('Error text here.');
- }else{
- update_post_meta($post['ID'], 'my_field', $attachment['my_field']);
- }
- }
- return $post;
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // altering the appearance of custom taxonomy inputs
- // on post edit screen
- //-------------------------------------------------------------------
- add_action('admin_head','remove_bath_parents');
- //--------------------------------------
- function remove_bath_parents() {
- //--------------------------------------
- global $pagenow;
- //-----------------------------------------
- // Only for the post add & edit pages
- //-----------------------------------------
- if (in_array($pagenow,array('post-new.php','post.php'))) {
- $css=<<<STYLE
- <style>
- <!--
- #newbath_parent {
- display:none;
- }
- -->
- </style>
- STYLE;
- echo $css;
- }
- }
- //-----------------------------------------
- add_action('init','add_homes_and_baths');
- //-----------------------------------------
- function add_homes_and_baths() {
- //-----------------------------------------
- register_post_type('home',
- array(
- 'label' => 'Homes',
- 'public' => true,
- 'rewrite' => array('slug' => 'homes'),
- 'hierarchical' => false,
- )
- );
- register_taxonomy('bath', 'home', array(
- 'hierarchical' => true,
- 'label' => 'Baths',
- 'rewrite' => array('slug' => 'baths' ),
- )
- );
- }
- //-----------------------------------------
- add_action('add_meta_boxes',
- 'mysite_add_meta_boxes',10,2);
- //-----------------------------------------
- function mysite_add_meta_boxes(
- $post_type, $post) {
- //-----------------------------------------
- ob_start();
- }
- //-----------------------------------------
- add_action('dbx_post_sidebar',
- 'mysite_dbx_post_sidebar');
- //-----------------------------------------
- function mysite_dbx_post_sidebar() {
- //-----------------------------------------
- $html = ob_get_clean();
- $html = str_replace('"checkbox"','"radio"',$html);
- echo $html;
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // add content above the post title on post edit screen
- //-------------------------------------------------------------------
- function wpse27700_above_title_content()
- {
- ?>
- <style>
- /*
- You might need to attach some styles here,
- to not get into the admin notices styles
- */
- </style>
- <h1>TEST</h1>
- <p>This is a test message</p>
- <?php
- }
- //-------------------------------------------
- // This is needed to only hook
- // on the post new & edit screens.
- //-------------------------------------------
- function wpse27700_admin_head()
- {
- add_action( 'admin_notices', 'wpse27700_above_title_content', 9999 );
- }
- //-----------------------------------------------
- add_action( 'admin_head-post-new.php', 'wpse27700_admin_head' );
- add_action( 'admin_head-post.php', 'wpse27700_admin_head' );
- ?>
- <?php
- //-------------------------------------------------------------------
- // add image below all on post edit screen
- // and then move it up via jQuery
- //-------------------------------------------------------------------
- add_action( 'dbx_post_sidebar',
- 'wpse27700_add_image' );
- //-----------------------------------------
- function wpse27700_add_image()
- //-----------------------------------------
- {
- echo '<img id="wpse27700-image" src="http://placebear.com/500/100"
- alt="wpse27700 bear" style="display:none;" />';
- }
- add_action( 'admin_head',
- 'wpse27700_admin_head' );
- //-----------------------------------------
- function wpse27700_admin_head()
- //-----------------------------------------
- {
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- var wpse27700 = jQuery('#wpse27700-image');
- wpse27700.remove();
- jQuery('#titlediv #titlewrap').before(wpse27700.show());
- });
- </script>
- <?php
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // change category checkboxes to radiobuttons
- // on post edit screen
- //-------------------------------------------------------------------
- add_action('add_meta_boxes',
- 'mysite_add_meta_boxes',10,2);
- //-----------------------------------------
- function mysite_add_meta_boxes(
- $post_type, $post) {
- //-----------------------------------------
- ob_start();
- }
- //-----------------------------------------
- add_action('dbx_post_sidebar',
- 'mysite_dbx_post_sidebar');
- //-----------------------------------------
- function mysite_dbx_post_sidebar() {
- //-----------------------------------------
- $html = ob_get_clean();
- $html = str_replace('"checkbox"','"radio"',$html);
- echo $html;
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // display custom taxonomy input as radiogroup
- // on custom post edit screen
- //-------------------------------------------------------------------
- class My_Radio_Tax{
- static $taxonomy = 'event-category'; // Slug of taxonomy
- static $post_type = 'event'; // Post type for meta-box
- //-----------------------------------------
- function load(){
- add_action( 'admin_menu', array(__CLASS__,'remove_meta_box'));
- add_action( 'add_meta_boxes', array(__CLASS__,'add_meta_box'));
- }
- //-----------------------------------------
- //Remove taxonomy meta box
- //-----------------------------------------
- function remove_meta_box(){
- //-------------------------------------------------------
- // The taxonomy metabox ID.
- // This is different for non-hierarchical taxonomies
- //---------------------------------------------------
- $tax_mb_id = self::$taxonomy.'div';
- remove_meta_box($tax_mb_id, self::$post_type, 'normal');
- }
- //-----------------------------------------
- //Add new taxonomy meta box
- //-----------------------------------------
- function add_meta_box() {
- add_meta_box( 'my_tax', 'My taxonomy',array(__CLASS__,'metabox_inner'),'event' ,'side','core');
- }
- //-----------------------------------------
- // Callback to set up metabox
- //-----------------------------------------
- function metabox_inner( $post ) {
- //-----------------------------------------
- //Get taxonomy and terms
- //-------------------------------------
- $taxonomy = self::$taxonomy;
- $tax = get_taxonomy($taxonomy);
- $name = 'tax_input[' . $taxonomy . ']';
- $terms = get_terms('event-category',array('hide_empty' => 0));
- //-------------------------------------
- //Get current and popular terms
- //-------------------------------------
- $popular = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC',
- 'number' => 10, 'hierarchical' => false ) );
- $postterms = get_the_terms( $post->ID,$taxonomy );
- $current = ($postterms ? array_pop($postterms) : false);
- $current = ($current ? $current->term_id : 0);
- ?>
- <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
- <!-- Display tabs-->
- <ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">
- <li class="tabs"><a href="#<?php echo $taxonomy; ?>-all" tabindex="3"><?php
- echo $tax->labels->all_items; ?></a></li>
- <li class="hide-if-no-js"><a href="#<?php
- echo $taxonomy; ?>-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
- </ul>
- <!-- Display popular taxonomy terms -->
- <div id="<?php echo $taxonomy; ?>-pop" class="tabs-panel" style="display: none;">
- <ul id="<?php echo $taxonomy; ?>checklist-pop" class="categorychecklist form-no-clear" >
- <?php foreach($popular as $term){
- $id = "id='in-popular-event-category-$term->term_id'";
- echo "<li id='popular-event-category-$taxonomy-$term->term_id'>
- <label class='selectit'>";
- echo "<input type='radio' {$id} name='{$name}'".
- checked($current,$term->term_id,false).
- "value='$term->term_id' />$term->name<br />";
- echo "</label></li>";
- }?>
- </ul>
- </div>
- <!-- Display taxonomy terms -->
- <div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
- <ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php
- echo $taxonomy?> categorychecklist form-no-clear">
- <?php foreach($terms as $term){
- $id = "id='in-event-category-$term->term_id'";
- echo "<li id='event-category-$taxonomy-$term->term_id'>
- <label class='selectit'>";
- echo "<input type='radio' {$id} name='{$name}'".
- checked($current,$term->term_id,false).
- "value='$term->term_id' />$term->name<br />";
- echo "</label></li>";
- }?>
- </ul>
- </div>
- </div>
- <?php
- }
- }
- My_Radio_Tax::load();
- ?>
- <?php
- //-------------------------------------------------------------------
- // get plugin name
- //-------------------------------------------------------------------
- $x = plugin_basename(__FILE__);
- ?>
- <?php
- //-------------------------------------------------------------------
- // manipulating with dashboard widgets
- //-------------------------------------------------------------------
- class Wptuts_Dashboard_Widgets {
- function __construct() {
- add_action( 'wp_dashboard_setup', array( $this, 'remove_dashboard_widgets' ) );
- add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widgets' ) );
- }
- function remove_dashboard_widgets() {
- }
- function add_dashboard_widgets() {
- }
- }
- $wdw = new Wptuts_Dashboard_Widgets();
- ?>
- <?php
- //-------------------------------------------------------------------
- // add and remove dashboard widgets
- //-------------------------------------------------------------------
- $remove_defaults_widgets = array(
- 'dashboard_incoming_links' => array(
- 'page' => 'dashboard',
- 'context' => 'normal'
- ),
- 'dashboard_right_now' => array(
- 'page' => 'dashboard',
- 'context' => 'normal'
- ),
- 'dashboard_recent_drafts' => array(
- 'page' => 'dashboard',
- 'context' => 'side'
- ),
- 'dashboard_quick_press' => array(
- 'page' => 'dashboard',
- 'context' => 'side'
- ),
- 'dashboard_plugins' => array(
- 'page' => 'dashboard',
- 'context' => 'normal'
- ),
- 'dashboard_primary' => array(
- 'page' => 'dashboard',
- 'context' => 'side'
- ),
- 'dashboard_secondary' => array(
- 'page' => 'dashboard',
- 'context' => 'side'
- ),
- 'dashboard_recent_comments' => array(
- 'page' => 'dashboard',
- 'context' => 'normal'
- )
- );
- //----------------------------------------
- $custom_dashboard_widgets = array(
- 'my-dashboard-widget' => array(
- 'title' => 'My Dashboard Widget',
- 'callback' =>
- //--------------------------
- 'dashboardWidgetContent'
- //--------------------------
- )
- );
- //----------------------------------------
- function dashboardWidgetContent() {
- //----------------------------------------
- $user = wp_get_current_user();
- echo "Hello <strong>" . $user->user_login .
- "</strong>, this is your custom widget.
- You can, for instance, list all the posts you've published:";
- $r = new WP_Query( apply_filters( 'widget_posts_args', array(
- 'posts_per_page' => 10,
- 'post_status' => 'publish',
- 'author' => $user->ID
- ) ) );
- if ( $r->have_posts() ) :
- ?>
- <?php
- endif;
- }
- //----------------------------------------
- require_once( plugin_dir_path( __FILE__ ) . '/custom_widgets.php' );
- //----------------------------------------
- function remove_dashboard_widgets() {
- //----------------------------------------
- global $remove_defaults_widgets;
- foreach ( $remove_defaults_widgets as $wigdet_id => $options ) {
- remove_meta_box( $wigdet_id, $options['page'], $options['context'] );
- }
- }
- //----------------------------------------
- function add_dashboard_widgets() {
- //----------------------------------------
- global $custom_dashboard_widgets;
- foreach ( $custom_dashboard_widgets as $widget_id => $options ) {
- wp_add_dashboard_widget(
- $widget_id,
- $options['title'],
- $options['callback']
- );
- }
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // output categories as list of checkboxes
- //-------------------------------------------------------------------
- $selected_cats = array( 45, 33, 118 );
- $checked_ontop = true;
- wp_category_checklist( 0, 0, $selected_cats, false, null, $checked_ontop );
- ?>
- <?php
- //-------------------------------------------------------------------
- // sanitize post_title as html class name
- //-------------------------------------------------------------------
- // If you want to explicitly style a post,
- // you can use the sanitized version of the post title as a class
- $post_class = sanitize_html_class( $post->post_title );
- echo '<div class="' . esc_attr( $post_class ) . '">';
- //-------------------------------------------------------------------
- // output navigation menu assigned to 'primary' menu block
- //-------------------------------------------------------------------
- ?>
- <div id="access" role="navigation">
- <?php /*
- Allow screen readers / text browsers to skip the navigation menu and
- get right to the good stuff. */ ?>
- <div class="skip-link screen-reader-text">
- <a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>">
- <?php _e( 'Skip to content', 'twentyten' ); ?></a>
- </div>
- <?php /*
- Our navigation menu. If one isn't filled out, wp_nav_menu falls
- back to wp_page_menu. The menu assigned to the primary position is
- the one used. If none is assigned, the menu with the lowest ID is
- used. */
- wp_nav_menu( array( 'container_class' => 'menu-header',
- 'theme_location' => 'primary' ) ); ?>
- </div><!-- #access -->
- <?php
- //-------------------------------------------------------------------
- // altering output of wp_nav_menu
- //-------------------------------------------------------------------
- function my_wp_nav_menu_args( $args = '' ) {
- //---------------------------------------------
- $args['container'] = false;
- return $args;
- }
- //---------------------------------------------
- add_filter( 'wp_nav_menu_args',
- 'my_wp_nav_menu_args' );
- //---------------------------------------------
- wp_nav_menu( array( 'items_wrap' => '%3$s' ) );
- //---------------------------------------------
- wp_nav_menu( array( 'theme_location' => 'primary',
- 'items_wrap' =>
- '<ul><li id="item-id">Menu: </li>%3$s</ul>' ) );
- //---------------------------------------------
- add_filter('nav_menu_css_class' ,
- 'special_nav_class' , 10 , 2);
- //---------------------------------------------
- function special_nav_class($classes, $item){
- //---------------------------------------------
- if(is_single() && $item->title == "Blog"){
- $classes[] = "special-class";
- }
- return $classes;
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // use custom menu Walker class
- //-------------------------------------------------------------------
- class themeslug_walker_nav_menu extends Walker_Nav_Menu {
- //----------------------------------------
- // add classes to ul sub-menus
- //----------------------------------------
- //---------------------------------------
- function start_lvl( &$output, $depth ) {
- //---------------------------------------
- //-----------------------------
- // depth dependent classes
- //-----------------------------
- $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' );
- $display_depth = ( $depth + 1);
- $classes = array(
- 'sub-menu',
- ( $display_depth % 2 ? 'menu-odd' : 'menu-even' ),
- ( $display_depth >=2 ? 'sub-sub-menu' : '' ),
- 'menu-depth-' . $display_depth
- );
- $class_names = implode( ' ', $classes );
- // build html
- $output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n";
- }
- //----------------------------------------
- // add main/sub classes to li's and links
- //----------------------------------------
- //----------------------------------------------
- function start_el(
- &$output, $item, $depth, $args ) {
- //----------------------------------------------
- global $wp_query;
- $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' );
- //----------------------------
- // depth dependent classes
- //----------------------------
- $depth_classes = array(
- ( $depth == 0 ? 'main-menu-item' : 'sub-menu-item' ),
- ( $depth >=2 ? 'sub-sub-menu-item' : '' ),
- ( $depth % 2 ? 'menu-item-odd' : 'menu-item-even' ),
- 'menu-item-depth-' . $depth
- );
- $depth_class_names = esc_attr( implode( ' ', $depth_classes ) );
- //----------------------------
- // passed classes
- //----------------------------
- $classes = empty( $item->classes ) ? array() : (array) $item->classes;
- $class_names = esc_attr( implode( ' ',
- apply_filters( 'nav_menu_css_class',
- array_filter( $classes ), $item ) ) );
- //----------------------------
- // build html
- //----------------------------
- $output .= $indent . '<li id="nav-menu-item-'. $item->ID .
- '" class="' . $depth_class_names . ' ' . $class_names . '">';
- //----------------------------
- // link attributes
- //----------------------------
- $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
- $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
- $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
- $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
- $attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';
- //----------------------------
- $item_output = sprintf( '%1$s <a %2$s > %3$s %4$s %5$s </a> %6$s',
- $args->before,
- $attributes,
- $args->link_before,
- apply_filters( 'the_title', $item->title, $item->ID ),
- $args->link_after,
- $args->after
- );
- //----------------------------
- // build html
- //----------------------------
- $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
- }
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // select menu according to whether user is logged in
- //-------------------------------------------------------------------
- if ( is_user_logged_in() ) {
- wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) );
- } else {
- wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) );
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // add css class to parent menu items
- //-------------------------------------------------------------------
- add_filter( 'wp_nav_menu_objects',
- 'add_menu_parent_class' );
- //-------------------------------------------
- function add_menu_parent_class( $items ) {
- //-------------------------------------------
- $parents = array();
- foreach ( $items as $item ) {
- if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
- $parents[] = $item->menu_item_parent;
- }
- }
- foreach ( $items as $item ) {
- if ( in_array( $item->ID, $parents ) ) {
- $item->classes[] = 'menu-parent-item';
- }
- }
- return $items;
- }
- //-------------------------------------------------------------------
- // using disabled function
- //-------------------------------------------------------------------
- ?>
- <input type=\"radio\" name=\"attachments\"
- value=\"<?php echo esc_attr( $value ); ?>\" <?php disabled( $value1, $value2, false ); ?> />
- <?php
- //-------------------------------------------------------------------
- // using custom Walker class
- //-------------------------------------------------------------------
- class Walker_Simple_Example extends Walker {
- //--------------------------------------------------------
- // Set the properties of the element
- // which give the ID of the current item and its parent
- //--------------------------------------------------------
- var $db_fields = array( 'parent' => 'parent_id', 'id' => 'object_id' );
- //--------------------------------------------------------
- // Displays start of a level. E.g '<ul>'
- // @see Walker::start_lvl()
- //--------------------------------------------------------
- function start_lvl(&$output, $depth=0, $args=array()) {
- $output .= "\n<ul>\n";
- }
- //--------------------------------------------------------
- // Displays end of a level. E.g '</ul>'
- // @see Walker::end_lvl()
- //--------------------------------------------------------
- function end_lvl(&$output, $depth=0, $args=array()) {
- $output .= "</ul>\n";
- }
- //--------------------------------------------------------
- // Displays start of an element. E.g '<li> Item Name'
- // @see Walker::start_el()
- //--------------------------------------------------------
- function start_el(&$output, $item, $depth=0, $args=array()) {
- $output. = "<li>".esc_attr($item->label);
- }
- //--------------------------------------------------------
- // Displays end of an element. E.g '</li>'
- // @see Walker::end_el()
- //--------------------------------------------------------
- function end_el(&$output, $item, $depth=0, $args=array()) {
- $output .= "</li>\n";
- }
- }
- $elements=array();
- echo Walker_Simple_Example::walk($elements);
- ?>
- <?php
- //-------------------------------------------------------------------
- // output menu using custom menu Walker class
- // (exclude top level of menu)
- //-------------------------------------------------------------------
- wp_nav_menu( array(
- 'theme_location'=>'primary',
- 'walker' =>
- new SH_Child_Only_Walker(),
- 'depth' => 0) );
- //-----------------------------------------------------
- class SH_Child_Only_Walker extends Walker_Nav_Menu {
- //-----------------------------------------------------
- //--------------------------------
- // Don't start the top level
- //--------------------------------
- function start_lvl(&$output, $depth=0,
- $args=array()) {
- //--------------------------------
- if( 0 == $depth )
- return;
- parent::start_lvl(&$output, $depth,$args);
- }
- //--------------------------------
- // Don't end the top level
- //--------------------------------
- function end_lvl(&$output, $depth=0,
- $args=array()) {
- //--------------------------------
- if( 0 == $depth )
- return;
- parent::end_lvl(&$output, $depth,$args);
- }
- //--------------------------------
- // Don't print top-level elements
- //--------------------------------
- function start_el(
- &$output, $item, $depth=0,
- $args=array()) {
- //--------------------------------
- if( 0 == $depth )
- return;
- parent::start_el(&$output, $item, $depth, $args);
- }
- //--------------------------------
- function end_el(&$output, $item, $depth=0,
- $args=array()) {
- //--------------------------------
- if( 0 == $depth )
- return;
- parent::end_el(&$output, $item, $depth, $args);
- }
- //--------------------------------
- // Only follow down one branch
- //--------------------------------
- function display_element( $element,
- &$children_elements,
- $max_depth,
- $depth=0,
- $args,
- &$output ) {
- //--------------------------------
- //------------------------------------------------
- // Check if element as a 'current element' class
- //------------------------------------------------
- $current_element_markers =
- array(
- 'current-menu-item',
- 'current-menu-parent',
- 'current-menu-ancestor' );
- $current_class = array_intersect(
- $current_element_markers,
- $element->classes );
- //------------------------------------------------
- // If element has a 'current' class,
- // it is an ancestor of the current element
- //------------------------------------------------
- $ancestor_of_current = !empty($current_class);
- //------------------------------------------------
- // If this is a top-level link and not the current,
- // or ancestor of the current menu item - stop here.
- //------------------------------------------------
- if ( 0 == $depth && !$ancestor_of_current)
- return
- parent::display_element(
- $element,
- &$children_elements,
- $max_depth,
- $depth,
- $args,
- &$output );
- }
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // add custom options page and help tab for it
- //-------------------------------------------------------------------
- add_action('admin_menu',
- 'my_admin_add_page');
- //------------------------------------
- function my_admin_add_page() {
- //------------------------------------
- global $my_admin_page;
- $my_admin_page = add_options_page(__('My Admin Page', 'map'), __('My Admin Page', 'map'),
- 'manage_options', 'map', 'my_admin_page');
- //---------------------------------------------
- // Adds my_help_tab when my_admin_page loads
- //---------------------------------------------
- add_action('load-'.$my_admin_page,
- 'my_admin_add_help_tab');
- }
- //------------------------------------
- function my_admin_add_help_tab () {
- //------------------------------------
- global $my_admin_page;
- $screen = get_current_screen();
- /*---------------------------------------------
- * Check if current screen is My Admin Page
- * Don't add help tab if it's not
- ---------------------------------------------*/
- if ( $screen->id != $my_admin_page )
- return;
- //-----------------------------------------------------
- // Add my_help_tab if current screen is My Admin Page
- //-----------------------------------------------------
- $screen->add_help_tab( array(
- 'id' => 'my_help_tab',
- 'title' => __('My Help Tab'),
- 'content' => '<p>' .
- __( 'Descriptive content that will show in My Help Tab-body goes here.' ) . '</p>',
- ) );
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // add help tab for all admin pages
- //-------------------------------------------------------------------
- class example_help
- {
- public $tabs = array(
- //---------------------------------------
- // The assoc key represents the ID
- // It is NOT allowed to contain spaces
- //---------------------------------------
- 'EXAMPLE' => array(
- 'title' => 'TEST ME!'
- ,'content' => 'FOO'
- )
- );
- //---------------------------------
- static public function init()
- //---------------------------------
- {
- $class = __CLASS__ ;
- new $class;
- }
- //---------------------------------
- public function __construct()
- //---------------------------------
- {
- add_action( "load-{$GLOBALS['pagenow']}",
- array( $this, 'add_tabs' ), 20 );
- }
- //---------------------------------
- public function add_tabs()
- //---------------------------------
- {
- foreach ( $this->tabs as $id => $data )
- {
- get_current_screen()->add_help_tab( array(
- 'id' => $id,
- 'title' => __( $data['title'], 'some_textdomain' )
- //-----------------------------------------------------------
- // Use the content only if you want to add something
- // static on every help tab.
- // Example: Another title inside the tab
- //-----------------------------------------------------------
- ,'content' => '<p>Some stuff that stays above every help text</p>'
- ,'callback' => array( $this,
- //------------------
- 'prepare'
- //------------------
- )
- ) );
- }
- }
- //---------------------------------
- public function prepare(
- $screen, $tab )
- //---------------------------------
- {
- printf(
- '<p>%s</p>'
- ,__(
- $tab['callback'][0]->tabs[ $tab['id'] ]['content']
- ,'dmb_textdomain'
- )
- );
- }
- }
- //--------------------------------------------------------------------------
- // Always add help tabs during "load-{$GLOBALS['pagenow'}".
- // There're some edge cases, as for example on reading options screen, your
- // Help Tabs get loaded before the built in tabs. This seems to be a core error.
- //--------------------------------------------------------------------------
- add_action( 'load-post.php', array( 'example_help', 'init' ) );
- add_action( 'load-post-new.php', array( 'example_help', 'init' ) );
- //-------------------------------------------------------------------
- // usage of esc_url and esc_url_raw
- //-------------------------------------------------------------------
- ?>
- <!-- Right -->
- <?php
- $url = 'http://wordpress.org';
- $response = wp_remote_get( esc_url_raw( $url ) ); // no need to espace entities
- if ( !is_wp_error( $response ) ) {
- echo wp_remote_retrieve_body( $response );
- }
- ?>
- <!-- Wrong! Use esc_url instead! -->
- <img src='<?php echo esc_url_raw( $url ); ?>' />
- <a href='<?php echo esc_url_raw( $url ); ?>'>WordPress</a>
- ?>
- <?php
- //-------------------------------------------------------------------
- // add images to media library and attach them to post
- //-------------------------------------------------------------------
- // $images is an array of image urls,
- // $id is the ID of the post I want the images to be attached to
- //---------------------------------------------------------------
- function oo_attach_images($images, $id){
- require_once(ABSPATH . '/wp-admin/includes/file.php');
- require_once(ABSPATH . '/wp-admin/includes/media.php');
- require_once(ABSPATH . '/wp-admin/includes/image.php');
- //---------------------------------------------
- foreach($images as $image){
- //------------------------------
- //array to mimic $_FILES
- //------------------------------
- $array = array(
- //------------------------------------------------------------
- // isolates and outputs the file name from its absolute path
- //------------------------------------------------------------
- 'name' => basename($image),
- 'type' => 'image/jpeg',
- //--------------------------------------------------
- // this field passes the actual path to the image
- //--------------------------------------------------
- 'tmp_name' => $image,
- 'error' => 0,
- //--------------------------------------------------
- // returns image filesize in bytes
- //--------------------------------------------------
- 'size' => filesize($image)
- );
- //--------------------------------------------------
- // the actual image processing, that is,
- // move to upload directory,
- // generate thumbnails and image sizes
- // and writing into the database happens here
- //--------------------------------------------------
- media_handle_sideload($array, $id);
- }
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // get file extension and mime type
- //-------------------------------------------------------------------
- $filetype = wp_check_filetype('image.jpg');
- echo $filetype['type'];
- echo $filetype['ext']; // will output jpg
- ?>
- <?php
- //-------------------------------------------------------------------
- // wrong way to use wp_handle_upload
- //-------------------------------------------------------------------
- define(‘WP_DEBUG’, true);
- $filename = "test.png";
- $tmpFile = download_url("http://url.com/testing/crop/".$filename);
- chmod($tmpFile, 0755);
- $mimeType = wp_check_filetype($_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename);
- $file_array = array(
- 'file' => $_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename,
- 'url' => $_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename,
- 'type' => $mimeType['type'],
- 'size' => filesize($_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename),
- 'name' => $filename,
- 'tmp_name' => $tmpFile
- );
- $image = wp_handle_upload($file_array,
- array('test_form' => FALSE,
- 'test_upload' => FALSE,
- 'test_type' => FALSE));
- print_r($file_array);
- print_r($image);
- unlink($tmpFile);
- ?>
- <?php
- //-------------------------------------------------------------------
- // using wp_handle_upload to add images to media library
- //-------------------------------------------------------------------
- if ( ! function_exists( 'wp_handle_upload' ) )
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
- $uploadedfile = $_FILES['file'];
- $upload_overrides = array( 'test_form' => false );
- //------------------------------------------------------
- $movefile = wp_handle_upload(
- $uploadedfile, $upload_overrides );
- //------------------------------------------------------
- if ( $movefile ) {
- echo "File is valid, and was successfully uploaded.\n";
- var_dump( $movefile);
- } else {
- echo "Possible file upload attack!\n";
- }
- ?>
- <?php
- //-------------------------------------------------------------------
- // get real file ext and sanitize file name
- //-------------------------------------------------------------------
- $validate = wp_check_filetype_and_ext( $file, $filename, $mimes );
- if( $validate['proper_filename'] !== false )
- $filename = $validate['proper_filename'];
- ?>
- <?php
- //-------------------------------------------------------------------
- // get theme modifications
- //-------------------------------------------------------------------
- $mods = get_theme_mods();
- var_dump($mods);
- ?>
- output example:
- array(2) { ["header_textcolor"]=> string(3) "333"
- ["header_image"]=> string(20) "random-default-image" }
- <?php var_dump($mods['header_textcolor']); ?>
- output example:
- string(3) "333"
- <?php
- //-------------------------------------------------------------------
- // registering shortcodes
- //-------------------------------------------------------------------
- // [bartag foo="foo-value"]
- //--------------------------------------
- function bartag_func( $atts ) {
- //--------------------------------------
- extract( shortcode_atts( array(
- 'foo' => 'something',
- 'bar' => 'something else',
- ), $atts ) );
- return "foo = {$foo}";
- }
- //--------------------------------------
- add_shortcode( 'bartag',
- 'bartag_func' );
- //----------------------------------------------
- function caption_shortcode( $atts,
- $content = null ) {
- //----------------------------------------------
- return '<span class="caption">' . $content . '</span>';
- }
- //----------------------------------------------
- function caption_shortcode( $atts,
- $content = null ) {
- //----------------------------------------------
- extract( shortcode_atts( array(
- 'class' => 'caption',
- ), $atts ) );
- return '<span class="' . esc_attr($class) . '">' . $content . '</span>';
- }
- //----------------------------------------------
- add_shortcode( 'caption',
- 'caption_shortcode' );
- //----------------------------------------------
- function add_shortcode( $tag, $func )
- function remove_shortcode( $tag )
- function remove_all_shortcodes()
- function shortcode_atts( $pairs, $atts )
- function do_shortcode( $content )
- ?>
- <?php
- //-------------------------------------------------------------------
- // add shortcode and MCE button for YouTube videos
- //-------------------------------------------------------------------
- //----------------------------------------
- function addYouTube($atts,
- $content = null) {
- //----------------------------------------
- extract(shortcode_atts(array( "id" => '' ), $atts));
- return
- '<p style="text-align:center"> \
- <a href="http://www.youtube.com/v/'.$id.'"> \
- <img src="http://img.youtube.com/vi/'.$id.'/0.jpg"
- width="400" height="300" class="aligncenter" /> \
- <span>Watch the video</span>
- </a></p>';
- }
- //----------------------------------------
- add_shortcode('youtube', 'addYouTube');
- //-------------------------------------------
- function add_youtube_button() {
- //-------------------------------------------
- if ( ! current_user_can('edit_posts') &&
- ! current_user_can('edit_pages') )
- return;
- if ( get_user_option('rich_editing') == 'true') {
- add_filter('mce_external_plugins',
- //-------------------------------
- 'add_youtube_tinymce_plugin'
- //-------------------------------
- );
- add_filter('mce_buttons',
- //-------------------------------
- 'register_youtube_button');
- //-------------------------------
- }
- }
- //----------------------------------------
- add_action('init',
- 'add_youtube_button');
- //-------------------------------------------
- function register_youtube_button($buttons) {
- //-------------------------------------------
- array_push($buttons, "|", "brettsyoutube");
- return $buttons;
- }
- //-------------------------------------------
- function add_youtube_tinymce_plugin(
- $plugin_array) {
- //-------------------------------------------
- $plugin_array['brettsyoutube'] = get_bloginfo('template_url').'/custom/editor_plugin.js';
- return $plugin_array;
- }
- //-------------------------------------------
- function my_refresh_mce($ver) {
- //-------------------------------------------
- $ver += 3;
- return $ver;
- }
- //-------------------------------------------
- add_filter( 'tiny_mce_version',
- 'my_refresh_mce')
- ?>
- //---------------------------------------------------
- // editor_plugin.js
- //---------------------------------------------------
- (function() {
- tinymce.create('tinymce.plugins.BrettsYouTube', {
- //--------------------------------
- init : function(ed, url) {
- //--------------------------------
- ed.addButton(
- //-----------------------
- 'brettsyoutube',
- //-----------------------
- {
- title : 'brettsyoutube.youtube',
- image : url+'/youtube.png',
- onclick : function() {
- idPattern = /(?:(?:[^v]+)+v.)?([^&=]{11})(?=&|$)/;
- var vidId = prompt("YouTube Video",
- "Enter the id or url for your video");
- var m = idPattern.exec(vidId);
- if (m != null && m != 'undefined')
- ed.execCommand('mceInsertContent', false,
- '[youtube id="'+m[1]+'"]');
- }
- });
- },
- //--------------------------------
- createControl : function(n, cm) {
- //--------------------------------
- return null;
- },
- //--------------------------------
- getInfo : function() {
- //--------------------------------
- return {
- longname : "Brett's YouTube Shortcode",
- author : 'Brett Terpstra',
- authorurl : 'http://brettterpstra.com/',
- infourl : 'http://brettterpstra.com/',
- version : "1.0"
- };
- }
- });
- tinymce.PluginManager.add('brettsyoutube', tinymce.plugins.BrettsYouTube);
- })();
- <?php
- //-------------------------------------------------------------------
- // add custom button to tinyMCE
- //-------------------------------------------------------------------
- add_filter('mce_external_plugins',
- "tinyplugin_register");
- add_filter('mce_buttons',
- 'tinyplugin_add_button', 0);
- //--------------------------------------------
- function tinyplugin_add_button($buttons)
- //--------------------------------------------
- {
- array_push($buttons, "separator", "tinyplugin");
- return $buttons;
- }
- //--------------------------------------------
- function tinyplugin_register($plugin_array)
- //--------------------------------------------
- {
- $url = trim(get_bloginfo('url'), "/";
- $url.= "/wp-content/plugins/tiny-plugin/editor_plugin.js";
- $plugin_array["tinyplugin"] = $url;
- return $plugin_array;
- }
- ?>
- //--------------------------------------------
- // editor_plugin.js
- //--------------------------------------------
- function tiny_plugin() {
- return "[tiny-plugin]";
- }
- //-----------------------------
- (function() {
- tinymce.create(
- 'tinymce.plugins.tinyplugin',
- {
- //--------------------------
- init :
- function(ed, url){
- //--------------------------
- ed.addButton(
- 'tinyplugin', {
- title : 'Insert TinyPlugin',
- onclick : function() {
- ed.execCommand(
- 'mceInsertContent',
- false,
- tiny_plugin()
- );
- },
- image: url + "/wand.png"
- });
- }
- });
- tinymce.PluginManager.add('tinyplugin', tinymce.plugins.tinyplugin);
- })();
- <?php
- //-------------------------------------------------------------------
- // Settings API
- //-------------------------------------------------------------------
- $default_options = array (
- 'pub_post_type' => 'post'
- );
- //---------------------------------
- add_option('dk_rss_digest_options', $default_options);
- //-------------------------------------------------
- add_settings_section(
- 'main_section',
- //------------------------
- 'General settings',
- //------------------------
- 'main_settings_section',
- //------------------------
- 'dk-main-menu');
- add_settings_field(
- 'pub_post_type',
- //-------------------
- 'Post type for publications',
- //------------------------
- 'pub_post_type_setting',
- //------------------------
- 'dk-main-menu',
- 'main_section');
- register_setting(
- 'dk_rss_digest_options',
- 'dk_rss_digest_options',
- //------------------------
- 'validate_options'
- //------------------------
- );
- //-------------------------------------------
- public function main_settings_section()
- //-------------------------------------------
- {
- echo '<h3>'.__('DK RSS Digest Settings').'</h3>';
- }
- //-------------------------------------------
- public function pub_post_type_setting()
- //-------------------------------------------
- {
- $excl = array('page','attachment','revision','nav_menu_item');
- if (isset($_POST['reg_post'])) {
- if ($_POST['reg_post']==1) {
- $this->dk_posttype();
- }
- else {
- array_push($excl, 'digest');
- }
- }
- $inf = get_post_types();
- $inf = array_diff($inf, $excl);
- echo '<select id="post_type_sel_inp"
- //--------------------------------------------
- name= "dk_rss_digest_options[pub_post_type]" >';
- //--------------------------------------------
- foreach ($inf as $ptype) {
- echo '<option value="'.$ptype.
- '" '.selected($this->_options['pub_post_type'],$ptype,false).' >'.
- $ptype.'</option>';
- }
- echo '</select>';
- }
- //-------------------------------------------
- public function validate_options($input)
- //-------------------------------------------
- {
- return $input;
- }
- //-------------------------------------------
- public function dk_menu_page()
- //-------------------------------------------
- {
- $this->_w('hook triggered', __METHOD__);
- echo '<h3>DK RSS Digest</h3>';
- echo '<ul><li><a href="'.admin_url('admin.php?page=dk-rss-management').'">'.
- __('RSS management').'</a></li>';
- echo '<li><a href="'.admin_url('admin.php?page=dk-digest-management').'">'.
- __('Publishing management').'</a></li>';
- echo '<li><a href="'.admin_url('admin.php?page=dk-help').'">'.__('Help').'</a></li>';
- echo '</ul>';
- ?>
- <form action="options.php" method="post">
- //-----------------------------------------------------
- <?php settings_fields( 'dk_rss_digest_options' ); ?>
- //-----------------------------------------------------
- <?php do_settings_sections('dk-main-menu'); ?>
- //-----------------------------------------------------
- <p class="submit">
- <input name="Submit" type="submit" value="<?php echo __('Save Changes'); ?>" />
- </p>
- </form>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement