Changeset 1603373
- Timestamp:
- 02/25/2017 09:53:38 AM (9 years ago)
- Location:
- botamp/trunk
- Files:
-
- 2 added
- 14 edited
-
README.md (modified) (1 diff)
-
admin/class-botamp-admin.php (modified) (2 diffs)
-
admin/partials/botamp-admin-display.php (modified) (1 diff)
-
api-resource/entity-type.php (modified) (1 diff)
-
api-resource/order-entity.php (modified) (1 diff)
-
api-resource/resource-proxy.php (modified) (3 diffs)
-
botamp-woocommerce/class-botamp-woocommerce-public.php (modified) (1 diff)
-
botamp.php (modified) (3 diffs)
-
includes/class-botamp-activator.php (modified) (3 diffs)
-
includes/class-botamp-deactivator.php (modified) (3 diffs)
-
includes/class-botamp-i18n.php (modified) (3 diffs)
-
includes/class-botamp-loader.php (modified) (8 diffs)
-
includes/class-botamp.php (modified) (15 diffs)
-
includes/shutdown-alert.php (added)
-
order_notifications.png (added)
-
public/partials/botamp-public-display.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
botamp/trunk/README.md
r1595064 r1603373 46 46 ### Order notifications 47 47 By enabling order notifications for Woocommerce, your customers can opt-in to receive messages from your Facebook page whenever their order status changes. 48 49  -
botamp/trunk/admin/class-botamp-admin.php
r1596226 r1603373 273 273 274 274 $html = '<select name = "' . $this->option( "{$args['post_type_name']}_entity_type" ) . '"class = "regular-list">'; 275 foreach ( $this->get_proxy( 'entity_type' )->all()->getBody()['data'] as $entity_type ) { 275 $entity_types = $this->get_proxy( 'entity_type' )->all()->getBody()['data']; 276 foreach ( $entity_types as $entity_type ) { 276 277 $entity_type_name = $entity_type['attributes']['name']; 277 278 $entity_type_label = $entity_type['attributes']['singular_label']; … … 350 351 $me_proxy->set_botamp_client( $new_api_key ); 351 352 $me_proxy->get(); 352 }353 354 public function shutdown_gracefully() {355 echo __( 'An unexpected error happened. The Botamp plugin has been deactivated.', 'botamp' );356 deactivate_plugins( plugin_dir_path( dirname( __FILE__ ) ) . 'botamp.php' );357 353 } 358 354 -
botamp/trunk/admin/partials/botamp-admin-display.php
r1596226 r1603373 6 6 * 7 7 * @link support@botamp.com 8 * @since 1.2. 18 * @since 1.2.2 9 9 * 10 10 * @package Botamp -
botamp/trunk/api-resource/entity-type.php
r1595064 r1603373 8 8 return $this->botamp->entityTypes->all(); 9 9 } 10 11 public function create_or_update() { 12 try { 13 $entity_type = $this->botamp->entityTypes->get( 'order' ); 14 $this->update( $entity_type ); 15 } catch (\Botamp\Exceptions\NotFound $e) { 16 $this->create(); 17 } 18 19 update_option( 'botamp_order_entity_type_created', 'ok' ); 20 } 21 22 private function create() { 23 $this->botamp->entityTypes->create([ 24 'name' => 'order', 25 'singular_label' => 'Order', 26 'plural_label' => 'Orders', 27 'platform' => 'woocommerce', 28 ]); 29 } 30 31 private function update( $entity_type ) { 32 $entity_type_attributes = $entity_type->getBody()['data']['attributes']; 33 if ( 'woocommerce' !== $entity_type_attributes['platform'] ) { 34 $entity_type_attributes['platform'] = 'woocommerce'; 35 $entity_type_id = $entity_type->getBody()['data']['id']; 36 37 $this->botamp->entityTypes->update( $entity_type_id, $entity_type_attributes ); 38 } 39 } 10 40 } -
botamp/trunk/api-resource/order-entity.php
r1595064 r1603373 97 97 98 98 private function get_product_image_url( $product_id ) { 99 $product = new WC_Product( $product_id ); 100 $attachment_id = $product->get_gallery_attachment_ids()[0]; 101 return wp_get_attachment_image_src( $attachment_id )['url']; 99 $image_id = get_post_thumbnail_id( $product_id ); 100 return wp_get_attachment_image_src( $image_id, 'single-post-thumbnail' ); 102 101 } 103 102 } -
botamp/trunk/api-resource/resource-proxy.php
r1595064 r1603373 14 14 15 15 public function __construct( $resource_code ) { 16 add_action( 'shutdown', array( $this, 'gracefully_fail' ) ); 17 16 18 $this->resources = [ 17 19 'product_entity' => new ProductEntity(), … … 30 32 31 33 try { 34 if ( $this->current_resource == $this->resources['order_entity'] ) { 35 if ( get_option( 'botamp_order_entity_type_created' ) !== 'ok' ) { 36 (new EntityType())->create_or_update(); 37 } 38 } 32 39 return call_user_func_array( [ $this->current_resource, $method ], $arguments ); 33 40 } catch (Botamp\Exceptions\Unauthorized $e) { … … 36 43 } 37 44 } 45 46 public function gracefully_fail() { 47 $last_error = error_get_last(); 48 if ( E_ERROR === $last_error['type'] ) { 49 deactivate_plugins( plugin_dir_path( dirname( __FILE__ ) ) . 'botamp.php' ); 50 51 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/shutdown-alert.php'; 52 echo $shutdown_alert; 53 54 exit; 55 } 56 } 38 57 } -
botamp/trunk/botamp-woocommerce/class-botamp-woocommerce-public.php
r1595064 r1603373 27 27 28 28 echo '<input type="hidden" name="botamp_contact_ref" value="' . $ref . '"> 29 <div id="notifications"><h3>' . __( 'Notifications' ) . '</h3>'; 29 <div id="notifications"><h3>' . __( 'Notifications' ) . '</h3> 30 <span>' . __( 'Get notifications about your order' ) . '</span>'; 30 31 31 32 require 'includes/messenger-script.php'; -
botamp/trunk/botamp.php
r1596226 r1603373 9 9 * 10 10 * @link support@botamp.com 11 * @since 1.2. 111 * @since 1.2.2 12 12 * @package Botamp 13 13 * … … 16 16 * Plugin URI: https://botamp.com 17 17 * Description: Botamp plugin for Wordpress. The easiest way to sync your WordPress site content with Botamp. 18 * Version: 1.2. 118 * Version: 1.2.2 19 19 * Author: Botamp, Inc. <support@botamp.com> 20 20 * Author URI: support@botamp.com … … 64 64 * not affect the page life cycle. 65 65 * 66 * @since 1.2. 166 * @since 1.2.2 67 67 */ 68 68 function run_botamp() { -
botamp/trunk/includes/class-botamp-activator.php
r1596226 r1603373 4 4 * 5 5 * @link support@botamp.com 6 * @since 1.2. 16 * @since 1.2.2 7 7 * 8 8 * @package Botamp … … 15 15 * This class defines all code necessary to run during the plugin's activation. 16 16 * 17 * @since 1.2. 117 * @since 1.2.2 18 18 * @package Botamp 19 19 * @subpackage Botamp/includes … … 28 28 * Long Description. 29 29 * 30 * @since 1.2. 130 * @since 1.2.2 31 31 */ 32 32 public static function activate() { -
botamp/trunk/includes/class-botamp-deactivator.php
r1596226 r1603373 4 4 * 5 5 * @link support@botamp.com 6 * @since 1.2. 16 * @since 1.2.2 7 7 * 8 8 * @package Botamp … … 15 15 * This class defines all code necessary to run during the plugin's deactivation. 16 16 * 17 * @since 1.2. 117 * @since 1.2.2 18 18 * @package Botamp 19 19 * @subpackage Botamp/includes … … 27 27 * Long Description. 28 28 * 29 * @since 1.2. 129 * @since 1.2.2 30 30 */ 31 31 public static function deactivate() { -
botamp/trunk/includes/class-botamp-i18n.php
r1596226 r1603373 7 7 * 8 8 * @link support@botamp.com 9 * @since 1.2. 19 * @since 1.2.2 10 10 * 11 11 * @package Botamp … … 19 19 * so that it is ready for translation. 20 20 * 21 * @since 1.2. 121 * @since 1.2.2 22 22 * @package Botamp 23 23 * @subpackage Botamp/includes … … 30 30 * Load the plugin text domain for translation. 31 31 * 32 * @since 1.2. 132 * @since 1.2.2 33 33 */ 34 34 public function load_plugin_textdomain() { -
botamp/trunk/includes/class-botamp-loader.php
r1596226 r1603373 4 4 * 5 5 * @link support@botamp.com 6 * @since 1.2. 16 * @since 1.2.2 7 7 * 8 8 * @package Botamp … … 26 26 * The array of actions registered with WordPress. 27 27 * 28 * @since 1.2. 128 * @since 1.2.2 29 29 * @access protected 30 30 * @var array $actions The actions registered with WordPress to fire when the plugin loads. … … 35 35 * The array of filters registered with WordPress. 36 36 * 37 * @since 1.2. 137 * @since 1.2.2 38 38 * @access protected 39 39 * @var array $filters The filters registered with WordPress to fire when the plugin loads. … … 44 44 * Initialize the collections used to maintain the actions and filters. 45 45 * 46 * @since 1.2. 146 * @since 1.2.2 47 47 */ 48 48 public function __construct() { … … 56 56 * Add a new action to the collection to be registered with WordPress. 57 57 * 58 * @since 1.2. 158 * @since 1.2.2 59 59 * @param string $hook The name of the WordPress action that is being registered. 60 60 * @param object $component A reference to the instance of the object on which the action is defined. … … 70 70 * Add a new filter to the collection to be registered with WordPress. 71 71 * 72 * @since 1.2. 172 * @since 1.2.2 73 73 * @param string $hook The name of the WordPress filter that is being registered. 74 74 * @param object $component A reference to the instance of the object on which the filter is defined. … … 85 85 * collection. 86 86 * 87 * @since 1.2. 187 * @since 1.2.2 88 88 * @access private 89 89 * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). … … 112 112 * Register the filters and actions with WordPress. 113 113 * 114 * @since 1.2. 1114 * @since 1.2.2 115 115 */ 116 116 public function run() { -
botamp/trunk/includes/class-botamp.php
r1596226 r1603373 7 7 * 8 8 * @link support@botamp.com 9 * @since 1.2. 19 * @since 1.2.2 10 10 * 11 11 * @package Botamp … … 22 22 * version of the plugin. 23 23 * 24 * @since 1.2. 124 * @since 1.2.2 25 25 * @package Botamp 26 26 * @subpackage Botamp/includes … … 33 33 * the plugin. 34 34 * 35 * @since 1.2. 135 * @since 1.2.2 36 36 * @access protected 37 37 * @var Botamp_Loader $loader Maintains and registers all hooks for the plugin. … … 42 42 * The unique identifier of this plugin. 43 43 * 44 * @since 1.2. 144 * @since 1.2.2 45 45 * @access protected 46 46 * @var string $plugin_name The string used to uniquely identify this plugin. … … 51 51 * The current version of the plugin. 52 52 * 53 * @since 1.2. 153 * @since 1.2.2 54 54 * @access protected 55 55 * @var string $version The current version of the plugin. … … 64 64 * the public-facing side of the site. 65 65 * 66 * @since 1.2. 166 * @since 1.2.2 67 67 */ 68 68 public function __construct() { 69 69 70 70 $this->plugin_name = 'botamp'; 71 $this->version = '1.2. 1';71 $this->version = '1.2.2'; 72 72 73 73 $this->load_dependencies(); … … 94 94 * with WordPress. 95 95 * 96 * @since 1.2. 196 * @since 1.2.2 97 97 * @access private 98 98 */ … … 136 136 * with WordPress. 137 137 * 138 * @since 1.2. 1138 * @since 1.2.2 139 139 * @access private 140 140 */ … … 151 151 * of the plugin. 152 152 * 153 * @since 1.2. 1153 * @since 1.2.2 154 154 * @access private 155 155 */ … … 157 157 $plugin_admin = new Botamp_Admin( $this->get_plugin_name(), $this->get_version() ); 158 158 159 $this->loader->add_action( 'shutdown', $plugin_admin, 'shutdown_gracefully' );160 159 $this->loader->add_action( 'update_option_botamp_api_key', $plugin_admin, 'on_api_key_change', 10, 2 ); 161 160 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); … … 195 194 * of the plugin. 196 195 * 197 * @since 1.2. 1196 * @since 1.2.2 198 197 * @access private 199 198 */ … … 209 208 * Run the loader to execute all of the hooks with WordPress. 210 209 * 211 * @since 1.2. 1210 * @since 1.2.2 212 211 */ 213 212 public function run() { … … 219 218 * WordPress and to define internationalization functionality. 220 219 * 221 * @since 1.2. 1220 * @since 1.2.2 222 221 * @return string The name of the plugin. 223 222 */ … … 229 228 * The reference to the class that orchestrates the hooks with the plugin. 230 229 * 231 * @since 1.2. 1230 * @since 1.2.2 232 231 * @return Botamp_Loader Orchestrates the hooks of the plugin. 233 232 */ … … 239 238 * Retrieve the version number of the plugin. 240 239 * 241 * @since 1.2. 1240 * @since 1.2.2 242 241 * @return string The version number of the plugin. 243 242 */ -
botamp/trunk/public/partials/botamp-public-display.php
r1596226 r1603373 6 6 * 7 7 * @link support@botamp.com 8 * @since 1.2. 18 * @since 1.2.2 9 9 * 10 10 * @package Botamp
Note: See TracChangeset
for help on using the changeset viewer.