Plugin Directory

Changeset 729145


Ignore:
Timestamp:
06/21/2013 01:41:40 AM (13 years ago)
Author:
borgboy
Message:

Made compatible for PHP 5.3.x and added activation check for same

Location:
article-forge/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • article-forge/trunk/ArticleForge.php

    r728624 r729145  
    120120
    121121        /** Paths **/
    122         $this->file       = __FILE__;
     122        $this->file       = __FILE__;//WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'ArticleForge.php';
    123123        $this->basename   = plugin_basename( $this->file );
    124124        $this->plugin_dir = plugin_dir_path( $this->file );
     
    174174                        $cquery->next_post();
    175175                        if ($cquery->post->post_status == 'draft') {
    176                             if (is_user_logged_in() && ($cquery->post->post_author == get_current_user_id()) && ($_GET['preview'] == 'true')) {
     176                            if (is_user_logged_in() && ($cquery->post->post_author == get_current_user_id())
     177                                && (array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true'))) {
    177178                                $section = $cquery->post;
    178179                            }
     
    213214                    if (isset($post_post)) {
    214215                        $statuses = array('publish');
    215                         if (is_user_logged_in() && ($post_post->post_author == get_current_user_id()) && ($_GET['preview'] == 'true')) array_push($statuses, 'draft');
     216                        if (is_user_logged_in() && ($post_post->post_author == get_current_user_id())
     217                            && (array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true'))) array_push($statuses, 'draft');
    216218                        // use author id and _GET to determine if we should allow draft to $statuses
    217219                        // get section from post id and section name
  • article-forge/trunk/ArticleForge/Admin/Settings.php

    r728624 r729145  
    3535    private $value;
    3636    public function __construct($value) {
    37         $this->value = (new NumericInteger)->validate($value);
     37        $temp = new NumericInteger;
     38        $this->value = $temp->validate($value);
    3839    }
    3940    public function validate($value) {
    40         $value = (new NumericInteger)->validate($value);
     41        $temp = new NumericInteger;
     42        $value = $temp->validate($value);
    4143        if ($value < $this->value) throw new ValidationException("Value must be greater than equal to " . $this->value);
    4244        return $value;
     
    206208    }
    207209
     210    private function get_error_msg( $name ) {
     211        $error = get_error( $name );
     212        if ( $error ) return $error['message']['msg'];
     213        return null;
     214    }
     215
     216    private function get_error_value( $name ) {
     217        $error = get_error( $name );
     218        if ( $error ) return $error['message']['value'];
     219        return null;
     220    }
     221
    208222    public function enqueue_scripts( $hook ) {
    209223        if ($hook == 'settings_page_' . af_namespace()) {
     
    358372?>
    359373
    360     <input name="<?php echo af_namespace(); ?>_options[summaries_per_page]" type="text" id="_<?php echo af_namespace(); ?>_summaries_per_page" class="regular-text code" value="<?php esc_attr_e($this->has_error('summaries_per_page') ? $this->get_error('summaries_per_page')['message']['value'] : $this->options->summaries_per_page); ?>" />
    361     <?php if ( $this->has_error('summaries_per_page') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error('summaries_per_page')['message']['msg'] ?></span><?php } ?>
     374    <input name="<?php echo af_namespace(); ?>_options[summaries_per_page]" type="text" id="_<?php echo af_namespace(); ?>_summaries_per_page" class="regular-text code" value="<?php esc_attr_e($this->has_error('summaries_per_page') ? $this->get_error_value('summaries_per_page') : $this->options->summaries_per_page); ?>" />
     375    <?php if ( $this->has_error('summaries_per_page') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error_msg('summaries_per_page') ?></span><?php } ?>
    362376
    363377<?php
     
    391405?>
    392406
    393     <input name="<?php echo af_namespace(); ?>_options[list_slug]" type="text" id="_<?php echo af_namespace(); ?>_list_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('list_slug') ? $this->get_error('list_slug')['message']['value'] : $this->options->list_slug); ?>" />
    394     <?php if ( $this->has_error('list_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error('list_slug')['message']['msg'] ?></span><?php } ?>
     407    <input name="<?php echo af_namespace(); ?>_options[list_slug]" type="text" id="_<?php echo af_namespace(); ?>_list_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('list_slug') ? $this->get_error_value('list_slug') : $this->options->list_slug); ?>" />
     408    <?php if ( $this->has_error('list_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error_msg('list_slug') ?></span><?php } ?>
    395409
    396410<?php
     
    408422?>
    409423
    410     <input name="<?php echo af_namespace(); ?>_options[single_slug]" type="text" id="_<?php echo af_namespace(); ?>_single_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('single_slug') ? $this->get_error('single_slug')['message']['value'] : $this->options->single_slug); ?>" />
    411     <?php if ( $this->has_error('single_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error('single_slug')['message']['msg'] ?></span><?php } ?>
     424    <input name="<?php echo af_namespace(); ?>_options[single_slug]" type="text" id="_<?php echo af_namespace(); ?>_single_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('single_slug') ? $this->get_error_value('single_slug') : $this->options->single_slug); ?>" />
     425    <?php if ( $this->has_error('single_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error_msg('single_slug') ?></span><?php } ?>
    412426
    413427<?php
     
    417431?>
    418432
    419     <input name="<?php echo af_namespace(); ?>_options[section_slug]" type="text" id="_<?php echo af_namespace(); ?>_section_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('section_slug') ? $this->get_error('section_slug')['message']['value'] : $this->options->section_slug); ?>" />
    420     <?php if ( $this->has_error('section_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error('section_slug')['message']['msg'] ?></span><?php } ?>
     433    <input name="<?php echo af_namespace(); ?>_options[section_slug]" type="text" id="_<?php echo af_namespace(); ?>_section_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('section_slug') ? $this->get_error_value('section_slug') : $this->options->section_slug); ?>" />
     434    <?php if ( $this->has_error('section_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error_msg('section_slug') ?></span><?php } ?>
    421435
    422436<?php
     
    426440?>
    427441
    428     <input name="<?php echo af_namespace(); ?>_options[arthur_slug]" type="text" id="_<?php echo af_namespace(); ?>_arthur_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('arthur_slug') ? $this->get_error('arthur_slug')['message']['value'] : $this->options->arthur_slug); ?>" />
    429     <?php if ( $this->has_error('arthur_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error('arthur_slug')['message']['msg'] ?></span><?php } ?>
     442    <input name="<?php echo af_namespace(); ?>_options[arthur_slug]" type="text" id="_<?php echo af_namespace(); ?>_arthur_slug" class="regular-text code" value="<?php esc_attr_e($this->has_error('arthur_slug') ? $this->get_error_value('arthur_slug') : $this->options->arthur_slug); ?>" />
     443    <?php if ( $this->has_error('arthur_slug') ) { ?><span class="articleforge-settings-error"><?php echo $this->get_error_msg('arthur_slug') ?></span><?php } ?>
    430444
    431445<?php
  • article-forge/trunk/ArticleForge/Install.php

    r728624 r729145  
    3737    /** Uses update instead of add to prevent overriding existing options **/
    3838    public static function activate() {
     39        // Validate PHP version, TODO: validate WP version
     40        // TODO: Clean this up
     41        if ( version_compare(PHP_VERSION, '5.3.0', '>') ) {
     42            deactivate_plugins( plugin_basename(dirname(dirname(__FILE__))) . '/main.php', true );
     43            wp_die("Article Forge requires at least PHP v5.3.0; you're version: " . PHP_VERSION . "   " .
     44                "<a href='" . admin_url('plugins.php') . "'>Return to plugins page</a>");
     45        }
    3946    }
    4047
Note: See TracChangeset for help on using the changeset viewer.