芝麻web文件管理V1.00
编辑当前文件:/home/ezdajrnh/www/wp-content/plugins/facebook-for-woocommerce/includes/Utilities/Tracker.php
get_connection_handler(); if ( $connection_handler ) { $connection_is_happy = $connection_handler->is_connected() && ! get_transient( 'wc_facebook_connection_invalid' ); } $data['extensions']['facebook-for-woocommerce']['is-connected'] = wc_bool_to_string( $connection_is_happy ); /** * Synchronization will always be permitted once we initiate the process of syncing all WooCommerce products. * * @since 3.5.3 */ $is_woo_all_products_enabled = facebook_for_woocommerce()->get_integration()->is_woo_all_products_enabled(); if ( ! $is_woo_all_products_enabled ) { $product_sync_enabled = facebook_for_woocommerce()->get_integration()->is_product_sync_enabled(); $data['extensions']['facebook-for-woocommerce']['product-sync-enabled'] = wc_bool_to_string( $product_sync_enabled ); } else { $data['extensions']['facebook-for-woocommerce']['product-sync-enabled'] = wc_bool_to_string( true ); } /** * How long did the last feed generation take (or did it fail - 0)? This counts just the time when the batches have been generated. * It does not take into account the time between the batches. * * @since 2.6.0 */ $feed_generation_time = get_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_TIME ); $data['extensions']['facebook-for-woocommerce']['feed-generation-time'] = floatval( $feed_generation_time ); /** * How long did the last feed generation take in wall time. This is the whole duration. Batches plus time in between. * * @since 2.6.6 */ if ( facebook_for_woocommerce()->get_integration()->is_new_style_feed_generation_enabled() ) { $feed_generation_batch_wall_time = intval( get_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_WALL_TIME ) ); } else { // For old feed generator this is the same thing $feed_generation_time because the process is done in one step. $feed_generation_batch_wall_time = intval( $feed_generation_time ); } $data['extensions']['facebook-for-woocommerce']['feed-generation-wall-time'] = $feed_generation_batch_wall_time; /** * Has the feed file been requested since the last snapshot? * * @since 2.6.0 */ $feed_file_requested = get_transient( self::TRANSIENT_WCTRACKER_FEED_REQUESTED ); $data['extensions']['facebook-for-woocommerce']['feed-file-requested'] = wc_bool_to_string( $feed_file_requested ); // Manually delete the transient. This prop tracks if feed has been requested _since last snapshot_. delete_transient( self::TRANSIENT_WCTRACKER_FEED_REQUESTED ); /** * Miscellaneous Facebook config settings. * * @since 2.6.0 */ $config = get_transient( self::TRANSIENT_WCTRACKER_FBE_BUSINESS_CONFIG ); $data['extensions']['facebook-for-woocommerce']['instagram-shopping-enabled'] = wc_bool_to_string( $config ? $config['ig_shopping_enabled'] : false ); $data['extensions']['facebook-for-woocommerce']['instagram-cta-enabled'] = wc_bool_to_string( $config ? $config['ig_cta_enabled'] : false ); /** * Feed pull / upload settings configured in Facebook UI. * * @since 2.6.0 */ $data['extensions']['facebook-for-woocommerce']['product-feed-config'] = get_transient( self::TRANSIENT_WCTRACKER_FB_FEED_CONFIG ); /** * Detect if the user has enabled the new experimental feed generator feature. * * @since 2.6.6 */ $data['extensions']['facebook-for-woocommerce']['new-feed-generator-enabled'] = wc_bool_to_string( facebook_for_woocommerce()->get_integration()->is_new_style_feed_generation_enabled() ); return $data; } /** * Update transient with feed file generation time. * * Note this is used to clear the transient (set to -1) to track feed generation failure. * * @param float $time_in_seconds Time taken to generate feed file (in seconds). * @since 2.6.0 */ public function track_feed_file_generation_time( $time_in_seconds ) { set_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_TIME, $time_in_seconds, self::TRANSIENT_WCTRACKER_LIFE_TIME ); } /** * Reset the feed generation in batch time counter. * * @since 2.6.6 */ public function reset_batch_generation_time() { // Reset the main counter. $this->track_feed_file_generation_time( -1 ); set_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_TIME, 0, self::TRANSIENT_WCTRACKER_LIFE_TIME ); set_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_WALL_TIME, 0, self::TRANSIENT_WCTRACKER_LIFE_TIME ); set_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_WALL_START_TIME, time(), self::TRANSIENT_WCTRACKER_LIFE_TIME ); } /** * Add time to batch feed_generation_time. * This accumulates time over all of the calculated feed batches. * * @param float $time_in_seconds Time to add to the generation time(in seconds). * @since 2.6.6 */ public function increment_batch_generation_time( $time_in_seconds ) { $tracked_generation_time = floatval( get_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_TIME ) ); set_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_TIME, floatval( $time_in_seconds ) + $tracked_generation_time, self::TRANSIENT_WCTRACKER_LIFE_TIME ); } /** * Save batch generation time. * * This is the last step in batch feed generation time tracking. * The accumulated time value is copied to the main transient * that is later used by the tracking code to track feed generation time. * * @since 2.6.6 */ public function save_batch_generation_time() { $this->track_feed_file_generation_time( get_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_TIME ) ); $start = intval( get_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_WALL_START_TIME ) ); $end = time(); set_transient( self::TRANSIENT_WCTRACKER_FEED_GENERATION_BATCH_WALL_TIME, $end - $start, self::TRANSIENT_WCTRACKER_LIFE_TIME ); } /** * Store the fact that the feed has been requested by Facebook in a transient. * This will later be added to next tracker snapshot. * * @since 2.6.0 */ public function track_feed_file_requested() { set_transient( self::TRANSIENT_WCTRACKER_FEED_REQUESTED, true, self::TRANSIENT_WCTRACKER_LIFE_TIME ); } /** * Store some Facebook config settings for tracking. * * @param bool $ig_shopping_enabled True if Instagram Shopping is configured. * @param bool $ig_cta_enabled True if `ig_cta` config option is enabled. * @since 2.6.0 */ public function track_facebook_business_config( bool $ig_shopping_enabled, bool $ig_cta_enabled ) { $transient = [ 'ig_shopping_enabled' => $ig_shopping_enabled, 'ig_cta_enabled' => $ig_cta_enabled, ]; set_transient( self::TRANSIENT_WCTRACKER_FBE_BUSINESS_CONFIG, $transient, self::TRANSIENT_WCTRACKER_LIFE_TIME ); } /** * Store Facebook feed config for tracking. * * @param array $feed_settings Key-value array of settings to add to tracker snapshot. * @since 2.6.0 */ public function track_facebook_feed_config( array $feed_settings ) { set_transient( self::TRANSIENT_WCTRACKER_FB_FEED_CONFIG, $feed_settings, self::TRANSIENT_WCTRACKER_LIFE_TIME ); } }