Plugin Directory

Changeset 1772955


Ignore:
Timestamp:
11/22/2017 10:17:21 AM (8 years ago)
Author:
jasie
Message:

new option saving works

Location:
widget-pagination/trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • widget-pagination/trunk/admin/class-widget-pagination-admin.php

    r1772382 r1772955  
    109109        //wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widget-pagination-admin.css', array(), $this->version, 'all' );
    110110
     111        // Enqueue only on our plugin page
    111112        if ( 'settings_page_widget-pagination' == get_current_screen() -> id ) {
    112 //                    wp_register_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widget-pagination-admin.css' );
    113 //                    wp_enqueue_style( $this->plugin_name );
    114 
    115 //                            wp_register_style('wgpag-style',
    116 //                                            plugins_url('/css/admin.css',__FILE__),
    117 //                                                              '', WGPAG_VERSION );
    118 
    119 //                    wp_register_style('colorpicker',
    120 //                                    plugins_url('/css/jquery.colorpicker.css',__FILE__));
    121 //                    wp_enqueue_style( $this->plugin_name );
    122 
    123113            wp_enqueue_style( 'wp-color-picker' );
    124114            wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widget-pagination-admin.css', array( 'wp-color-picker' ), $this->version, 'all' );
     
    148138        //wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/widget-pagination-admin.js', array( 'jquery' ), $this->version, false );
    149139
    150         //if ( 'settings_page_widget-pagination' == get_current_screen() -> id ) {
     140        // Enqueue only on our plugin page
     141        if ( 'settings_page_widget-pagination' == get_current_screen() -> id ) {
    151142            wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/widget-pagination-admin.js', array( 'jquery', 'wp-color-picker' ), $this->version, false );
    152         //} //TODO js condition
     143        }
     144
    153145    }
    154146
     
    213205        /*
    214206         *  Documentation: https://developer.wordpress.org/reference/functions/register_setting/
    215          */
    216         register_setting($this->plugin_name, $this->plugin_name, array($this, 'validate'));
     207         *
     208         * string $option_group: A settings group name
     209         * string $option_name: The name of an option to sanitize and save
     210         * array $sanitize_callback
     211         */
     212        register_setting( $this->plugin_name, $this->plugin_short, array($this, 'validate') );
    217213
    218214    }
  • widget-pagination/trunk/admin/partials/widget-pagination-admin-display.php

    r1772382 r1772955  
    1616<!-- This file should primarily consist of HTML with a little bit of PHP. -->
    1717
    18 <?php
    19 $options_before_v1 = get_option('wgpag_options');
    20 ?>
    21 
    2218<div class="wrap" id="wgpag-options">
    2319    <div class="icon32" id="icon-themes"></div>
    2420
    25     <h2>Widget Paginator <?php _e('Settings') ?></h2>
     21    <h2><?php _e('Settings') ?> › <?php echo esc_html(get_admin_page_title()); ?></h2>
    2622
    2723    <p>
     
    4541    //Grab all options
    4642    $options = get_option($this->plugin_short);
    47     // print '<pre>' . print_r ($options, true) . '</pre>';
     43    //print 'options: <pre>' . print_r ($options, true) . '</pre>';
     44
     45    $options_before_v1 = get_option('wgpag_options');
     46    //print 'old opt: <pre>' . print_r ($options_before_v1, true) . '</pre>';
    4847
    4948    // Pagination Options (saved or default value)
     
    7271    $style_options_hovItem_fontSz = isset($options['hover_item_style_font_size']) ? $options['hover_item_style_font_size'] : '';
    7372
    74     $pagStyle_options_bgClr = isset($options['pag_style_background_color']) ? $options['pagination_style_background_color'] : '';
     73    $pagStyle_options_bgClr = isset($options['pag_style_background_color']) ? $options['pag_style_background_color'] : '';
    7574    $pagStyle_options_borderClrTop = isset($options['pag_style_border_color_top']) ? $options['pag_style_border_color_top'] : '';
    7675    $pagStyle_options_borderClrBottom = isset($options['pag_style_border_color_bottom']) ? $options['pag_style_border_color_bottom'] : '';
    7776    $pagStyle_options_borderClrLeft = isset($options['pag_style_border_color_left']) ? $options['pag_style_border_color_left'] : '';
    7877    $pagStyle_options_borderClrRight = isset($options['pag_style_border_color_right']) ? $options['pag_style_border_color_right'] : '';
    79 
    80 
    81     settings_fields($this->plugin_short);
    82     do_settings_sections($this->plugin_short);
    8378    ?>
    8479
    85     <form method="post" action="#">
     80    <form method="post" name="wgpag_options" action="options.php">
     81        <?php
     82        settings_fields( $this->plugin_name ); // $option_group: This must match the group name used in register_setting(), which is the page slug name on which the form is to appear.
     83        do_settings_sections( $this->plugin_name ); // $page: The slug name of the page whose settings sections you want to output. This should match the page name used in add_settings_section().
     84        ?>
     85
    8686        <div class="metabox-holder" style="float:left; margin-right:3%;">
    8787            <div class="postbox">
     
    487487                            <input type="text" size="7" maxlength="7" class="color-picker"
    488488                                   id="<?php echo $this->plugin_short . '-hover_item_style_background_color' ?>"
    489                                    name="<?php echo $this->plugin_short . '[hover_item_style_baxkground_color]' ?>"
     489                                   name="<?php echo $this->plugin_short . '[hover_item_style_background_color]' ?>"
    490490                                   value="<?php echo $style_options_hovItem_bgClr ?>" />
    491491                            <span class="hint">
Note: See TracChangeset for help on using the changeset viewer.