Plugin Directory

Changeset 1345038


Ignore:
Timestamp:
02/07/2016 07:59:01 AM (10 years ago)
Author:
hogetan
Message:

fixed a bug.

Location:
add-page-from-template/trunk
Files:
9 added
2 edited

Legend:

Unmodified
Added
Removed
  • add-page-from-template/trunk/includes/class-loader.php

    r1323830 r1345038  
    9797    }
    9898
    99     /** Absorb shocks of version difference.
     99    /**
     100     * Absorb shocks of version difference.
    100101     * @see https://core.trac.wordpress.org/browser/tags/4.1/src/wp-admin/includes/post.php#L533
    101102     */
     
    113114     *
    114115     * thanks! the master of rewrite_rules!
    115      * https://github.com/yousan/add-page-from-template/issues/1#event-456557115
     116     * @link https://github.com/yousan/add-page-from-template/issues/1#event-456557115
    116117     */
    117118    private function register_update_rewrite_rules() {
     
    127128            add_rewrite_endpoint($template->getTemplateSlug(), EP_ROOT);
    128129        }
     130        flush_rewrite_rules();
    129131    }
    130132
  • add-page-from-template/trunk/includes/class-option.php

    r1323814 r1345038  
    11<?php
     2
    23/**
    34 * Created by PhpStorm.
     
    1617
    1718
    18     public static function getDefaults() {
     19    public static function getDefaults()
     20    {
    1921        return array(
    20             'is_aggressive' => false,
     22            'aggressive' => false,
    2123            'base_dir' => 'pages/',
    2224        );
     
    3032        AddPageFromTemplate::loadTextDomain();
    3133
    32         add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
    33         add_action( 'admin_init', array( $this, 'page_init' ) );
     34        add_action('admin_menu', array($this, 'add_plugin_page'));
     35        add_action('admin_init', array($this, 'page_init'));
    3436    }
    3537
     
    3941     * @return null
    4042     */
    41     static public function get_($varname) {
    42         $options = get_option( self::APFT_OPTION_NAME );
     43    static public function get_($varname)
     44    {
     45        $options = get_option(self::APFT_OPTION_NAME);
    4346        if (isset($options[$varname])) {
    4447            return $options[$varname];
     
    6063            'manage_options',
    6164            'apft-setting-admin',
    62             array( $this, 'create_admin_page' )
     65            array($this, 'create_admin_page')
    6366        );
    6467    }
     
    7073    {
    7174        // Set class property
    72         $this->options = get_option( self::APFT_OPTION_NAME );
     75        $this->options = get_option(self::APFT_OPTION_NAME);
    7376        ?>
    7477        <div class="wrap">
    75             <?php //screen_icon(); ?>
    76             <h2><?php _e('Add Page From Template (APFT)', 'apft')?></h2>
     78            <?php //screen_icon();
     79            ?>
     80            <h2><?php _e('Add Page From Template (APFT)', 'apft') ?></h2>
    7781            <form method="post" action="options.php">
    7882                <?php
    7983                // This prints out all hidden setting fields
    80                 settings_fields( 'apft_option_group' );
    81                 do_settings_sections( 'apft-setting-admin' );
     84                settings_fields('apft_option_group');
     85                do_settings_sections('apft-setting-admin');
    8286                submit_button();
    8387                ?>
     
    9599            'apft_option_group', // Option group
    96100            self::APFT_OPTION_NAME, // Option name
    97             array( $this, 'sanitize' ) // Sanitize
     101            array($this, 'sanitize') // Sanitize
    98102        );
    99103
     
    101105            'setting_apft', // ID
    102106            __('APFT Custom Settings', 'apft'), // Title
    103             array( $this, 'print_section_info' ), // Callback
     107            array($this, 'print_section_info'), // Callback
    104108            'apft-setting-admin' // Page
    105109        );
     
    108112            'is_aggressive', // ID
    109113            __("'Aggressive' flush_rewrite", 'apft'), // Title
    110             array( $this, 'is_aggressive_callback' ), // Callback
     114            array($this, 'is_aggressive_callback'), // Callback
    111115            'apft-setting-admin', // Page
    112116            'setting_apft' // Section
     
    116120            'base_dir',
    117121            __('Base Directory', 'apft'),
    118             array( $this, 'base_dir_callback' ),
     122            array($this, 'base_dir_callback'),
    119123            'apft-setting-admin',
    120124            'setting_apft'
     
    124128            'template_files',
    125129            __('Template Files', 'apft'),
    126             array( $this, 'template_files_callback' ),
     130            array($this, 'template_files_callback'),
    127131            'apft-setting-admin',
    128132            'setting_apft'
     
    136140     * @return array
    137141     */
    138     public function sanitize( $input )
     142    public function sanitize($input)
    139143    {
    140144        $new_input = array();
    141         if( isset( $input['aggressive'] ) ) {
     145        if (isset($input['aggressive'])) {
    142146            $new_input['aggressive'] = $input['aggressive'];
    143147        } else {
     
    145149        }
    146150
    147         if( isset( $input['title'] ) )
    148             $new_input['title'] = sanitize_text_field( $input['title'] );
     151        if (isset($input['title']))
     152            $new_input['title'] = sanitize_text_field($input['title']);
    149153
    150154        return $new_input;
     
    164168    public function is_aggressive_callback()
    165169    {
    166         if ( isset($this->options['aggressive']) && false == $this->options['aggressive'] ) {
     170        if (isset($this->options['aggressive']) && false == $this->options['aggressive']) {
    167171            $checked = '';
    168172        } else {
     
    181185     * ベースディレクトリの設定部分
    182186     */
    183     public function base_dir_callback() {
    184         if (isset( $this->options['base_dir'] )) {
    185             $base_dir = esc_attr( $this->options['base_dir']);
    186         }  else {
     187    public function base_dir_callback()
     188    {
     189        if (isset($this->options['base_dir'])) {
     190            $base_dir = esc_attr($this->options['base_dir']);
     191        } else {
    187192            $base_dir = 'pages/';
    188193        }
     
    199204     * @see _get_page_link()
    200205     */
    201     private function getPageLink($slug){
     206    private function getPageLink($slug)
     207    {
    202208        global $wp_rewrite;
    203209        $link = $wp_rewrite->get_page_permastruct();
     
    206212        $link = home_url($link);
    207213        $link = user_trailingslashit($link, 'page');
    208         return apply_filters( '_get_page_link', $link, 0 );
     214        return apply_filters('_get_page_link', $link, 0);
    209215    }
    210216
     
    212218     * テンプレートファイル一覧の設定部分
    213219     */
    214     public function template_files_callback() {
     220    public function template_files_callback()
     221    {
    215222        $templates = AP_TemplateSearcher::getTemplates();
    216223        ?>
    217224        <table class="widefat" id="apft-templates">
    218             <thead><tr class="head" style="cursor: move;">
     225            <thead>
     226            <tr class="head" style="cursor: move;">
    219227                <th scope="col"><?php _e('Template Name', 'apft'); ?></th>
    220228                <th scope="col"><?php _e('Status', 'apft'); ?></th>
     
    226234                <tr class="nodrag nodrop">
    227235                    <td><?php echo $template->slug; ?></td>
    228                     <td class="apft-status-<?php echo $template->status;?>">
     236                    <td class="apft-status-<?php echo $template->status; ?>">
    229237                        <?php _e(ucfirst($template->status), 'apft'); ?>
    230238                    </td>
     
    233241                    // ファイルパス テーマディレクトリから下 URLエンコードが必要
    234242                    // ex) pages%2Fpage-fuga.php
    235                     $filepath = urlencode(str_replace( get_stylesheet_directory().'/', '', $template->path));
     243                    $filepath = urlencode(str_replace(get_stylesheet_directory() . '/', '', $template->path));
    236244                    $themeName = basename(get_stylesheet_directory());
    237                     $editUrl = home_url('/wp-admin/theme-editor.php?file='.$filepath.'&theme='.$themeName);
     245                    $editUrl = home_url('/wp-admin/theme-editor.php?file=' . $filepath . '&theme=' . $themeName);
    238246                    ?>
    239247                    <td>
     
    252260                </tr>
    253261            <?php } ?>
    254 <!--            <tr class="nodrag nodrop">-->
    255 <!--                <td>&nbsp;</td>-->
    256 <!--                <td><i>Registration IP</i></td>-->
    257 <!--                <td><i>wpmem_reg_ip</i></td>-->
    258 <!--                <td colspan="5">&nbsp;</td>-->
    259 <!--                <td align="center">-->
    260 <!--                    <input type="checkbox" name="ut_fields[wpmem_reg_ip]" value="Registration IP">-->
    261 <!--                </td>-->
    262 <!--            </tr>-->
    263             </tbody></table>
     262            </tbody>
     263        </table>
    264264        <div class="footnote">
    265265            <?php _e('Status: Conflict means same slug alredy exists.'); ?>
     
    275275        printf(
    276276            '<input type="text" id="title" name="my_option_name[title]" value="%s" />',
    277             isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : ''
     277            isset($this->options['title']) ? esc_attr($this->options['title']) : ''
    278278        );
    279279    }
Note: See TracChangeset for help on using the changeset viewer.