Plugin Directory

Changeset 556588


Ignore:
Timestamp:
06/12/2012 09:59:38 AM (14 years ago)
Author:
manfer
Message:

requirements checking code reviewed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contact-form-7-bwp-recaptcha-extension/trunk/includes/CF7bwpCAPT.class.php

    r556016 r556588  
    1313
    1414        // member variables
    15         private $requirements_met;
    16         private $is_bwp_capt_active;
    17         private $is_cf7_active;
    1815        private $textdomain;
    1916        private $options_name;
     
    3835            $this->options_name = $options;
    3936            $this->options = get_option( $options );
    40             $this->requirements_met = $this->meets_requirements();
    4137
    4238            // register settings page
     
    4945
    5046            // register tag generator
    51             if ( $this->requirements_met ) {
     47            if ( $this->meets_requirements() ) {
    5248                add_action( 'admin_init', array( &$this, 'tag_generator_recaptcha' ), 46 );
    5349                add_action( 'admin_init', array( &$this, 'cf7_bwp_capt_register_styles' ) );
     
    5551
    5652            // register validation filter
    57             if ( $this->requirements_met ) {
     53            if ( $this->meets_requirements() ) {
    5854                add_filter( 'wpcf7_validate_recaptcha', array( &$this, 'recaptcha_validation_filter' ), 10, 2 );
    5955                add_filter( 'wpcf7_ajax_json_echo', array( &$this, 'ajax_json_echo_filter' ) );
     
    6965         */
    7066        function register_cf7_shortcode() {
    71             if ( function_exists( 'wpcf7_add_shortcode' ) && $this->requirements_met ) {
     67            if ( function_exists( 'wpcf7_add_shortcode' ) && $this->meets_requirements() ) {
    7268                wpcf7_add_shortcode( 'recaptcha', array( &$this, 'shortcode_handler' ), true );
    7369            }
     
    395391         */
    396392        function tag_generator_recaptcha() {
    397             if ( function_exists( 'wpcf7_add_tag_generator' ) && $this->requirements_met ) {
     393            if ( function_exists( 'wpcf7_add_tag_generator' ) && $this->meets_requirements() ) {
    398394                wpcf7_add_tag_generator(
    399395                    'recaptcha', // name
     
    465461                    <table>
    466462
    467                     <?php if ( ! $this->requirements_met ) : ?>
     463                    <?php if ( ! $this->meets_requirements() ) : ?>
    468464                        <tr>
    469465                            <td colspan="2">
     
    503499         */
    504500        function meets_requirements() {
    505             if ( ! isset( $this->requirements_met ) ) {
    506                 $this->requirements_met = $this->check_bwp_capt() && $this->check_cf7();
    507             }
    508 
    509             return $this->requirements_met;
     501            static $requirements_met;
     502            if ( ! isset( $requirements_met ) ) {
     503                $requirements_met = $this->check_bwp_capt() && $this->check_cf7();
     504            }
     505            return $requirements_met;
    510506        }
    511507
     
    514510         */
    515511        function check_bwp_capt() {
    516             include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    517             $this->is_bwp_capt_active = is_plugin_active('bwp-recaptcha/bwp-recaptcha.php');
    518             return $this->is_bwp_capt_active;
     512            static $is_bwp_capt_active;
     513            if ( ! isset( $is_bwp_capt_active ) ) {
     514                include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
     515                $is_bwp_capt_active = is_plugin_active('bwp-recaptcha/bwp-recaptcha.php');
     516            }
     517            return $is_bwp_capt_active;
    519518        }
    520519
     
    523522         */
    524523        function check_cf7() {
    525             include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    526             $this->is_cf7_active = is_plugin_active('contact-form-7/wp-contact-form-7.php');
    527             return $this->is_cf7_active;
     524            static $is_cf7_active;
     525            if ( ! isset( $is_cf7_active ) ) {
     526                include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
     527                $is_cf7_active = is_plugin_active('contact-form-7/wp-contact-form-7.php');
     528            }
     529            return $is_cf7_active;
    528530        }
    529531
     
    534536            global $plugin_page;
    535537
    536             if ( ! $this->is_cf7_active ) :
     538            if ( ! $this->check_cf7() ) :
    537539?>
    538540
     
    547549            endif;
    548550
    549             if ( ! $this->is_bwp_capt_active ) :
     551            if ( ! $this->check_bwp_capt() ) :
    550552
    551553?>
Note: See TracChangeset for help on using the changeset viewer.