Plugin Directory

Changeset 3045300


Ignore:
Timestamp:
03/05/2024 12:03:21 AM (2 years ago)
Author:
CloudSponge
Message:

releasing v2.6.0

Location:
better-sharing/trunk
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • better-sharing/trunk/BetterSharingWP.php

    r3026585 r3045300  
    66 * Plugin Name:       Better Sharing
    77 * Description:       Add essential viral sharing functionality to any WordPress site.
    8  * Version:           2.5.2
     8 * Version:           2.6.0
    99 * Author:            CloudSponge
    1010 * Author URI:        https://www.cloudsponge.com
     
    5454define( 'BETTER_SHARING_PATH', plugin_dir_path( __FILE__ ) );
    5555define( 'BETTER_SHARING_URI', plugin_dir_url( __FILE__ ) );
    56 define( 'BETTER_SHARING_VERSION', '2.5.2' );
     56define( 'BETTER_SHARING_VERSION', '2.6.0' );
    5757
    5858define( 'BETTER_SHARING_ADMIN_TEMPLATE_PATH', BETTER_SHARING_PATH . 'includes/AdminScreens/admin-templates/' );
     
    7272use BetterSharingWP\AddOns\CouponReferralProgram\CouponReferralProgram;
    7373use BetterSharingWP\AddOns\WooWishlists\WooWishlists;
     74use BetterSharingWP\AddOns\IgnitionDeck\IgnitionDeck;
    7475
    7576use BetterSharingWP\BSWP_DemoPage;
     
    169170    function() {
    170171        global $better_sharing_wp;
     172       
     173        $ignition_deck_addon = new IgnitionDeck();
     174        $better_sharing_wp->init_add_on( $ignition_deck_addon );
    171175
    172176        $automate_woo_addon = new AutomateWoo();
  • better-sharing/trunk/includes/Admin.php

    r3023683 r3045300  
    4646       
    4747        $this->addons_page      = new AddOns();
     48
    4849        $this->email_templates  = new EmailTemplate();
    49         // $default_email_template = $this->email_templates->create_default_email_template(); // ID or WP_Error
     50        $this->email_templates->init();
     51
    5052        $this->better_sharing_blocks    = new UITemplate();
     53        $this->better_sharing_blocks->init();
     54
    5155        $this->plugin_settings  = new PluginSettings();
    5256       
  • better-sharing/trunk/includes/AdminScreens/EmailTemplate.php

    r3026585 r3045300  
    6565        $this->set_default_email_subject();
    6666        $this->set_default_email_template_title();
    67         $this->init();
    6867    }
    6968
     
    9695        add_filter('manage_posts_columns', array( $this, 'add_id_column_to_admin_list' ), 5 );
    9796        add_filter('manage_edit-bswp_email_template_sortable_columns', array( $this, 'set_sortable_id_column' ) );
    98         add_action('manage_posts_custom_column', array( $this, 'print_id_column_content' ), 5, 2 );
     97        add_action('manage_posts_custom_column', array( $this, 'print_id_column_content' ), 10, 2 );
    9998    }
    10099
     
    281280     * on plugin activation
    282281     *
     282     * @param $post_title
    283283     * @return WP_Error The post ID on success. The WP_Error on failure.
    284284     */
    285     public function create_default_email_template(){
    286         $result = $this->get_default_email_template_id(); // exit if not false with the result( the ET ID).
    287        
     285    public function create_default_email_template( $post_title = '' ){
     286        if ( empty( trim( $post_title ) ) ) :
     287            $post_title = $this->default_email_template_title;
     288        endif;
     289        $result = $this->get_default_email_template_id( $post_title ); // exit if not false with the result( the ET ID).
     290     
    288291        if ( !$result ) :
    289292            $postarr = array(
    290293                'post_content' => $this->default_email_body,
    291                 'post_title'   =>  $this->default_email_template_title,
     294                'post_title'   =>  $post_title,
    292295                'post_status'  => 'publish',
    293296                'post_type'    => 'bswp_email_template',
    294297                'comment_status' => 'closed',
    295                 'post_name'    =>  $this->default_email_template_title, // post slug
     298                'post_name'    =>  $post_title, // post slug
    296299            );
    297300            // save default post and get ID.
     
    313316    }
    314317    /**
    315      * Gets or creates
    316      * default email template
    317      * exists
    318      *
     318     * Gets the
     319     * default email template
     320     * ID if it exists
     321     * or returns false
     322     *
     323     * @param str $post_title
    319324     * @return int|bool (the email template) ID|false
    320325     */
    321     public function get_default_email_template_id(){
    322         $result = post_exists(
    323             $this->default_email_template_title,
    324             $this->default_email_body,
    325             '', // date.
     326    public function get_default_email_template_id( $post_title = ''){
     327        if ( empty( trim( $post_title ) ) ) :
     328            $post_title = $this->default_email_template_title;
     329        endif;
     330        $result = $this->post_exists(
     331            $post_title,
     332            $this->default_email_body,
    326333            'bswp_email_template'
    327334        );
     
    337344    }
    338345    /**
     346     * Modified version of
     347     * the wp-core's post_exists()
     348     * Determines if a post exists
     349     * based on title, content and type.
     350     *
     351     * @param str $title
     352     * @param str $content
     353     * @param str $type
     354     * @return int
     355     */
     356    function post_exists( $title, $content = '', $type = '' ) {
     357        global $wpdb;
     358   
     359        $post_title   = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
     360        $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
     361        $post_type    = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) );
     362   
     363        $query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
     364        $args  = array();
     365   
     366        if ( ! empty( $title ) ) {
     367            $query .= ' AND post_title = %s';
     368            $args[] = $post_title;
     369        }
     370   
     371        if ( ! empty( $content ) ) {
     372            $query .= ' AND post_content = %s';
     373            $args[] = $post_content;
     374        }
     375   
     376        if ( ! empty( $type ) ) {
     377            $query .= ' AND post_type = %s';
     378            $args[] = $post_type;
     379        }
     380        if ( ! empty( $args ) ) {
     381            return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) );
     382        }
     383        return 0;
     384    }
     385   
     386    /**
    339387     * Checks default
    340388     * email template meta
     
    346394    public function default_email_template_meta_exists( $post_id ){
    347395        $meta = get_post_meta( $post_id, 'bswp_email_subject', true);
     396       
    348397        if ( $meta ) :
    349398            if ( $meta === $this->default_email_subject ) :
     
    10421091        return $link;
    10431092    }
     1093    /**
     1094     * Checks and updates
     1095     * the status of
     1096     * EmailTemplate
     1097     *
     1098     * @param int $email_template_ID
     1099     * @param str $status
     1100     * @return bool
     1101     */
     1102    public function update_email_template_status( $email_template_ID, $status ){
     1103        // check post status
     1104        $current_status = get_post_status( $email_template_ID ); // false on failure
     1105        if ( $current_status ) :
     1106            if ( $status == $current_status ) :
     1107                return true;
     1108            else :
     1109                // wp_update_post( array|object $postarr = array(), bool $wp_error = false, bool $fire_after_hooks = true ): int|WP_Error
     1110                $update_status = array(
     1111                    'ID' => $email_template_ID,
     1112                    'post_status' => $status
     1113                );
     1114                $status_update = wp_update_post($update_status);
     1115                if ( ! is_wp_error(  $status_update  ) ) :
     1116                    return true;
     1117                endif;
     1118            endif;
     1119        endif;
     1120        return false;
     1121    }
    10441122}
  • better-sharing/trunk/includes/AdminScreens/UITemplate.php

    r3023683 r3045300  
    5656        $this->set_default_ui_template_title();
    5757        $this->set_default_ui_template_settings();
    58         $this->init();
    5958    }
    6059
     
    7473
    7574        add_action( 'rest_api_init', array( $this, 'add_custom_field') );
     75        add_action( 'rest_api_init', array( $this, 'rest_init' ) );
    7676        //add ui template shortcode in cpt admin list
    7777        add_filter('manage_posts_columns', array( $this, 'add_shortcode_column_to_admin_list' ), 5 );
     
    8888     * @return void
    8989     */
    90     public function bswp_blocks_helper() { 
     90    public function bswp_blocks_helper( $views ) { 
    9191        $add_new_block_link = admin_url('post-new.php?post_type=bswp_ui_template'); // always available link.
    9292        $add_email_template_link =  admin_url('post-new.php?post_type=bswp_email_template'); // always available link.
     
    103103
    104104        add_action('manage_posts_custom_column', array( $this, 'print_shortcode_column_content' ), 5, 2 );
    105     }
     105        return $views;
     106    }
     107    /**
     108     * Rest Init
     109     *
     110     * @return void
     111     */
     112    public function rest_init() {
     113
     114        register_rest_route(
     115            'bswp/v1',
     116            '/bswp-ui-templates',
     117            array(
     118                'methods'  => array( 'GET' ),
     119                'callback' => array( $this, 'rest_get_ui_templates' ),
     120                'permission_callback' => '__return_true'
     121            )           
     122        );
     123    }
    106124    /**
    107125     * Registers
     
    240258     *
    241259     * @param arr $settings
     260     * @param str $post_status
    242261     * @return int|bool ID|false
    243262     */
    244     public function get_default_ui_template_id( $settings ){ 
     263    public function get_default_ui_template_id( $settings, $post_status = 'any' ){ 
    245264        $post_exists = false;
    246265        $posts = get_posts([
    247266            'post_type'  => 'bswp_ui_template',
    248267            'title' => $settings['post_title'],
    249             'post_status' => 'any',
     268            'post_status' => $post_status,
    250269        ]);  // UI templates with this title.
    251270        foreach ( $posts as $post ) :
     
    970989
    971990    /**
     991     * Gets all published
     992     * UI templates of a selected type
     993     *
     994     * @param [type] $type
     995     * @return array UI template ID and name
     996     */
     997    public function get_ui_templates( $type ){
     998        $compact_templates = [];
     999        $templates = get_posts([
     1000            'post_type' => 'bswp_ui_template',
     1001            'post_status' => 'publish',
     1002            'numberposts' => -1,
     1003          ]);
     1004       
     1005        if ( ! empty( $templates ) ) :
     1006            foreach ($templates as $template) :
     1007                $data = $this->get_bswp_ui_template_data( $template->ID );
     1008                if ( $type === $data['view_style'] ) :
     1009                   
     1010                    $current_template = [ 'id' => $template->ID, 'name' => $template->post_title ];
     1011                    array_push( $compact_templates, $current_template );
     1012                endif;
     1013            endforeach;
     1014        endif;
     1015
     1016        return $compact_templates;
     1017    }
     1018
     1019     /**
     1020     * Callback for the '/bswp-ui-templates'
     1021     * Gets all published
     1022     * UI templates of a selected type
     1023     * @param [type] $type
     1024     * @return array UI template ID and name
     1025     */
     1026    public function rest_get_ui_templates( $data){
     1027        $type = $data->get_param('type');
     1028        $result_templates = [];
     1029        $templates = get_posts([
     1030            'post_type' => 'bswp_ui_template',
     1031            'post_status' => 'publish',
     1032            'numberposts' => -1,
     1033          ]);
     1034       
     1035        if ( ! empty( $templates ) ) :
     1036            foreach ($templates as $template) :
     1037                $data = $this->get_bswp_ui_template_data( $template->ID );
     1038                if ( $type === $data['view_style'] ) :
     1039                   
     1040                    $current_template = [ 'id' => $template->ID, 'name' => $template->post_title ];
     1041                    array_push( $result_templates, $current_template );
     1042                endif;
     1043            endforeach;
     1044        endif;
     1045
     1046        return  $result_templates;
     1047    }
     1048
     1049    /**
     1050     * Gets BSWP UI Template CPT's
     1051     * settings
     1052     * @param integer $template_id
     1053     * @return array $template_data if template_id is 0 or non existing,
     1054     * the method returns the default BSWP UI Template CPT Settings
     1055     */
     1056    public function get_bswp_ui_template_data( $template_id ){   
     1057        //user passed an id
     1058        if( $template_id ){
     1059
     1060            $template_data = @unserialize(base64_decode( get_post_meta( $template_id, 'bswp_ui_template_settings', true ) ) ); 
     1061            //saved without base64 encoding will throw notice
     1062            if( $template_data === false ){
     1063
     1064                $template_data = unserialize( get_post_meta( $template_id, 'bswp_ui_template_settings', true ) );
     1065            }
     1066           
     1067            //template data doesn't exists, load default settings
     1068            if( !$template_data ){
     1069                //no valid template id provided, default settings are loaded
     1070                $template_data = $this->default_ui_template_settings;
     1071            }
     1072
     1073        } else {
     1074            //no template id provided, default settings are loaded
     1075            $template_data = $this->default_ui_template_settings;
     1076        }
     1077
     1078        return $template_data;
     1079    }
     1080
     1081    /**
    9721082     * Get the BSWP CPT
    9731083     * link to admin
  • better-sharing/trunk/includes/AdminScreens/admin-templates/addons-page.php

    r2717248 r3045300  
    9292                                            <?php $add_on->display_settings(); ?>
    9393                                        </div>
    94                                         <input class="button button-primary" type="submit" value="<?php _e('Save Settings', 'better-sharing-wp'); ?>" />
     94                                        <input class="button button-primary save-settings" type="submit" value="<?php _e('Save Settings', 'better-sharing-wp'); ?>" />
    9595                                    </form>
    9696                                </div>
  • better-sharing/trunk/readme.txt

    r3026585 r3045300  
    55Tested up to: 6.4
    66Requires PHP: 7.0
    7 Stable tag: 2.5.2
     7Stable tag: 2.6.0
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    7070== Changelog ==
    7171
     72= 2.6.0 =
     73* IgnitionDeck Crowdfunding Addon - Add Better Sharing functionality to your IgnitionDeck Crowdfunding projects.
     74
    7275= 2.5.2 =
    7376* Fixed conflict with "Simple Custom CSS and JS" plugin
  • better-sharing/trunk/vendor/composer/installed.php

    r3026585 r3045300  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '9b1b02a0368a0ddc75672c86e36ff493c8dc6d44',
     6        'reference' => '5ce5604743e5a9dd9f47a6f76caaa1b7f5b0b7ef',
    77        'type' => 'project',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '9b1b02a0368a0ddc75672c86e36ff493c8dc6d44',
     16            'reference' => '5ce5604743e5a9dd9f47a6f76caaa1b7f5b0b7ef',
    1717            'type' => 'project',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.