Changeset 3045300
- Timestamp:
- 03/05/2024 12:03:21 AM (2 years ago)
- Location:
- better-sharing/trunk
- Files:
-
- 8 added
- 7 edited
-
BetterSharingWP.php (modified) (4 diffs)
-
dist/addons/ignitiondeck.js (added)
-
includes/AddOns/IgnitionDeck (added)
-
includes/AddOns/IgnitionDeck/IgnitionDeck.php (added)
-
includes/AddOns/IgnitionDeck/assets (added)
-
includes/AddOns/IgnitionDeck/assets/index.js (added)
-
includes/AddOns/IgnitionDeck/assets/styles.scss (added)
-
includes/AddOns/IgnitionDeck/config (added)
-
includes/AddOns/IgnitionDeck/config/ignition-deck-hooks.php (added)
-
includes/Admin.php (modified) (1 diff)
-
includes/AdminScreens/EmailTemplate.php (modified) (7 diffs)
-
includes/AdminScreens/UITemplate.php (modified) (6 diffs)
-
includes/AdminScreens/admin-templates/addons-page.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
better-sharing/trunk/BetterSharingWP.php
r3026585 r3045300 6 6 * Plugin Name: Better Sharing 7 7 * Description: Add essential viral sharing functionality to any WordPress site. 8 * Version: 2. 5.28 * Version: 2.6.0 9 9 * Author: CloudSponge 10 10 * Author URI: https://www.cloudsponge.com … … 54 54 define( 'BETTER_SHARING_PATH', plugin_dir_path( __FILE__ ) ); 55 55 define( 'BETTER_SHARING_URI', plugin_dir_url( __FILE__ ) ); 56 define( 'BETTER_SHARING_VERSION', '2. 5.2' );56 define( 'BETTER_SHARING_VERSION', '2.6.0' ); 57 57 58 58 define( 'BETTER_SHARING_ADMIN_TEMPLATE_PATH', BETTER_SHARING_PATH . 'includes/AdminScreens/admin-templates/' ); … … 72 72 use BetterSharingWP\AddOns\CouponReferralProgram\CouponReferralProgram; 73 73 use BetterSharingWP\AddOns\WooWishlists\WooWishlists; 74 use BetterSharingWP\AddOns\IgnitionDeck\IgnitionDeck; 74 75 75 76 use BetterSharingWP\BSWP_DemoPage; … … 169 170 function() { 170 171 global $better_sharing_wp; 172 173 $ignition_deck_addon = new IgnitionDeck(); 174 $better_sharing_wp->init_add_on( $ignition_deck_addon ); 171 175 172 176 $automate_woo_addon = new AutomateWoo(); -
better-sharing/trunk/includes/Admin.php
r3023683 r3045300 46 46 47 47 $this->addons_page = new AddOns(); 48 48 49 $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 50 52 $this->better_sharing_blocks = new UITemplate(); 53 $this->better_sharing_blocks->init(); 54 51 55 $this->plugin_settings = new PluginSettings(); 52 56 -
better-sharing/trunk/includes/AdminScreens/EmailTemplate.php
r3026585 r3045300 65 65 $this->set_default_email_subject(); 66 66 $this->set_default_email_template_title(); 67 $this->init();68 67 } 69 68 … … 96 95 add_filter('manage_posts_columns', array( $this, 'add_id_column_to_admin_list' ), 5 ); 97 96 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 ); 99 98 } 100 99 … … 281 280 * on plugin activation 282 281 * 282 * @param $post_title 283 283 * @return WP_Error The post ID on success. The WP_Error on failure. 284 284 */ 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 288 291 if ( !$result ) : 289 292 $postarr = array( 290 293 'post_content' => $this->default_email_body, 291 'post_title' => $ this->default_email_template_title,294 'post_title' => $post_title, 292 295 'post_status' => 'publish', 293 296 'post_type' => 'bswp_email_template', 294 297 'comment_status' => 'closed', 295 'post_name' => $ this->default_email_template_title, // post slug298 'post_name' => $post_title, // post slug 296 299 ); 297 300 // save default post and get ID. … … 313 316 } 314 317 /** 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 319 324 * @return int|bool (the email template) ID|false 320 325 */ 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, 326 333 'bswp_email_template' 327 334 ); … … 337 344 } 338 345 /** 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 /** 339 387 * Checks default 340 388 * email template meta … … 346 394 public function default_email_template_meta_exists( $post_id ){ 347 395 $meta = get_post_meta( $post_id, 'bswp_email_subject', true); 396 348 397 if ( $meta ) : 349 398 if ( $meta === $this->default_email_subject ) : … … 1042 1091 return $link; 1043 1092 } 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 } 1044 1122 } -
better-sharing/trunk/includes/AdminScreens/UITemplate.php
r3023683 r3045300 56 56 $this->set_default_ui_template_title(); 57 57 $this->set_default_ui_template_settings(); 58 $this->init();59 58 } 60 59 … … 74 73 75 74 add_action( 'rest_api_init', array( $this, 'add_custom_field') ); 75 add_action( 'rest_api_init', array( $this, 'rest_init' ) ); 76 76 //add ui template shortcode in cpt admin list 77 77 add_filter('manage_posts_columns', array( $this, 'add_shortcode_column_to_admin_list' ), 5 ); … … 88 88 * @return void 89 89 */ 90 public function bswp_blocks_helper( ) {90 public function bswp_blocks_helper( $views ) { 91 91 $add_new_block_link = admin_url('post-new.php?post_type=bswp_ui_template'); // always available link. 92 92 $add_email_template_link = admin_url('post-new.php?post_type=bswp_email_template'); // always available link. … … 103 103 104 104 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 } 106 124 /** 107 125 * Registers … … 240 258 * 241 259 * @param arr $settings 260 * @param str $post_status 242 261 * @return int|bool ID|false 243 262 */ 244 public function get_default_ui_template_id( $settings ){263 public function get_default_ui_template_id( $settings, $post_status = 'any' ){ 245 264 $post_exists = false; 246 265 $posts = get_posts([ 247 266 'post_type' => 'bswp_ui_template', 248 267 'title' => $settings['post_title'], 249 'post_status' => 'any',268 'post_status' => $post_status, 250 269 ]); // UI templates with this title. 251 270 foreach ( $posts as $post ) : … … 970 989 971 990 /** 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 /** 972 1082 * Get the BSWP CPT 973 1083 * link to admin -
better-sharing/trunk/includes/AdminScreens/admin-templates/addons-page.php
r2717248 r3045300 92 92 <?php $add_on->display_settings(); ?> 93 93 </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'); ?>" /> 95 95 </form> 96 96 </div> -
better-sharing/trunk/readme.txt
r3026585 r3045300 5 5 Tested up to: 6.4 6 6 Requires PHP: 7.0 7 Stable tag: 2. 5.27 Stable tag: 2.6.0 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 70 70 == Changelog == 71 71 72 = 2.6.0 = 73 * IgnitionDeck Crowdfunding Addon - Add Better Sharing functionality to your IgnitionDeck Crowdfunding projects. 74 72 75 = 2.5.2 = 73 76 * Fixed conflict with "Simple Custom CSS and JS" plugin -
better-sharing/trunk/vendor/composer/installed.php
r3026585 r3045300 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 9b1b02a0368a0ddc75672c86e36ff493c8dc6d44',6 'reference' => '5ce5604743e5a9dd9f47a6f76caaa1b7f5b0b7ef', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 9b1b02a0368a0ddc75672c86e36ff493c8dc6d44',16 'reference' => '5ce5604743e5a9dd9f47a6f76caaa1b7f5b0b7ef', 17 17 'type' => 'project', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.