Plugin Directory

Changeset 968899


Ignore:
Timestamp:
08/20/2014 10:53:00 AM (11 years ago)
Author:
pricemesh
Message:

added support for custom post types

Location:
pricemesh/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pricemesh/trunk/admin/pricemesh-admin.php

    r963908 r968899  
    350350        $option_name = "WooCommerce";
    351351        $option_callback = "settings_3rd_party_woocommerce_callback";
     352        add_settings_field(
     353            $option, __($option_name, $this->plugin_slug), array($this, $option_callback), $this->plugin_slug, $section
     354        );
     355        register_setting($group, $option);
     356
     357        //custom post types
     358        $option = "pricemesh_option_custom_post_types";
     359        $option_name = "Custom Post Types";
     360        $option_callback = "settings_3rd_party_custom_post_types_callback";
    352361        add_settings_field(
    353362            $option, __($option_name, $this->plugin_slug), array($this, $option_callback), $this->plugin_slug, $section
     
    659668    }
    660669
    661 
    662     /**
     670    /**
     671     * custom post type callback
     672     * @since    1.5.1
     673     */
     674    public function settings_3rd_party_custom_post_types_callback(){
     675        $opts = self::get_pricemesh_settings();
     676        $setting = $opts["custom_post_types"];
     677        $name = "pricemesh_option_custom_post_types";
     678        echo "<input type='text' name='$name' id='$name' value='$setting' class='regular-text'/>";
     679        echo "<p class='description'>".
     680             " ".__("Liste von Custom Post Types bei denen Pricemesh angezeigt werden soll. Format: type1,type2,type3", $this->plugin_slug).
     681             "</p>";
     682    }
     683
     684    /**
    663685     * Render the settings page for this plugin.
    664686     *
     
    720742            add_meta_box('pricemesh-meta',__('Pricemesh', 'pricemesh-plugin'), array($this, 'meta_box'),'product','normal','high');
    721743        }
     744        //add meta boxes to all custom post types
     745        $custom_post_types = explode(",", $opts["custom_post_types"]);
     746        foreach($custom_post_types as $type){
     747            add_meta_box('pricemesh-meta',__('Pricemesh', 'pricemesh-plugin'), array($this, 'meta_box'),$type, 'normal','high');
     748        }
    722749    }
    723750
  • pricemesh/trunk/pricemesh-base.php

    r963908 r968899  
    3232            "wp_robot_integration" => get_option("pricemesh_option_wp_robot_integration", 0),
    3333            "woocommerce_integration" => get_option("pricemesh_option_woocommerce_integration", 0),
     34            "custom_post_types" => get_option("pricemesh_option_custom_post_types", ""),
    3435        );
    3536    }
  • pricemesh/trunk/pricemesh.php

    r942938 r968899  
    44Plugin URI: https://www.pricemesh.io/plugins/wordpress/
    55Description: Mit diesem Plugin ist es möglich Wordpress um einen eigenen Preisvergleich zu erweitern.
    6 Version: 1.4.2
     6Version: 1.5.1
    77Author: pricemesh
    88Author URI: https://www.pricemesh.io
  • pricemesh/trunk/public/pricemesh-public.php

    r963908 r968899  
    2222     * @var     string
    2323     */
    24     const VERSION = '1.5';
     24    const VERSION = '1.5.1';
    2525
    2626    /**
     
    308308
    309309    /**
     310     * Check if a post is a custom post type.
     311     * @param  mixed $post Post object or ID
     312     * @return boolean
     313     */
     314    public static function is_custom_post_type( $post = NULL )
     315    {
     316        $opts = self::get_pricemesh_settings();
     317        $custom_post_types = explode(",", $opts["custom_post_types"]);
     318        return is_singular($custom_post_types);
     319    }
     320
     321    /**
    310322     * Checks if Pricemesh should be injected on this page
    311323     * @since    1.0.0
     
    313325     */
    314326    public static function is_injection_needed(){
    315         if(is_single() || is_page()){
     327        if(is_single() || is_page() || self::is_custom_post_type()){
    316328            $opts = self::get_pricemesh_settings();
    317329            if(strlen($opts["pids"])>=8 && strlen($opts["token"])>5){
  • pricemesh/trunk/readme.txt

    r963908 r968899  
    44Requires at least: 3.4
    55Tested up to: 3.9.2
    6 Stable tag: 1.5
     6Stable tag: 1.5.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7373== Changelog ==
    7474
     75= 1.5.1 =
     76* Custom Post Types werden nun unterstützt
     77
    7578= 1.5 =
    7679* Dark Theme hinzugefügt
Note: See TracChangeset for help on using the changeset viewer.