extending the plugin with a class

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #4087
    Olly
    Admin & Mod

      you could write a plugin / class to extend the plugin like so :

      example:
      create a directory called ‘wppizza-custom’ in your plugins directory.
      add a file in said directory called ‘wppizza-custom.php’.
      add the following code to that file:

      
      <?php
      /*
      Plugin Name: WPPizza - Custom Vars
      Description:  WPPizza - Custom Vars
      Author: ollybach
      Plugin URI: http://www.wp-pizza.com
      Author URI: http://www.wp-pizza.com
      Version: 0.1
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
      ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
      WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
      DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
      ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
      ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
      SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      */
      if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
      add_action( 'plugins_loaded', 'wppizza_extend_custom_vars');
      function wppizza_extend_custom_vars(){
      if (!class_exists( 'WPPIZZA' )) {return;}
      class WPPIZZA_EXTEND_CUSTOM_VARS extends WPPIZZA{
      /************************************************************
      *
      *	[construct]
      *
      *************************************************************/
      function __construct() {
      parent::__construct();
      /**set/customise  vars**/
      $this->wppizza_set_custom_vars();
      }		
      function wppizza_set_custom_vars(){
      /**
      overwrite whatever needs overwriting
      to see all vars just do a
      print_r($this->pluginOptions)
      **/
      $this->pluginOptions['order']['order_pickup']=1;/*enable custom pickup for example even if it's not enabled in order settings*/
      }
      }
      }
      ?>
      
    Viewing 1 post (of 1 total)
    • The topic ‘extending the plugin with a class’ is closed to new replies.