ed. if ( ! empty( $replaced_ss_content ) || ! empty( $replaced_ss_iframe_content ) ) { $updated_post = [ 'ID' => $post_id, 'post_content' => ! empty( $replaced_ss_iframe_content ) ? $replaced_ss_iframe_content : $replaced_ss_content, ]; // Update the post. $result = wp_update_post( $updated_post ); if ( 0 != $result ) { /* translators: %d - Post ID */ aawp_log( 'Site Stripe Migration', sprintf( __( 'Migration completed for Post # %d', 'aawp' ), $post_id ) ); } } } /** * Migrate Site Stripe Links in a widget. * * @param string $widget_name The Widget name to migrate the Stripe Links of. * * @since 3.40.2 */ public function migrate_widget( $widget_name ) { $widgets = get_option( $widget_name ); $updated_widget = []; foreach ( $widgets as $key => $widget ) { if ( empty( $widget['content'] ) ) { $updated_widget[ $key ] = $widget; continue; } // Get updated content or false if Site Stripe Links not found. $replaced_ss_content = ( new Admin\Tools\Migrations() )->replace_site_stripe_links( $widget['content'] ); // If Site Stripe links doesn't exit, use post content else use replaced content. $replaced_ss_iframe_content = false === (bool) $replaced_ss_content ? ( new Admin\Tools\Migrations() )->replace_site_stripe_iframes( $widget['content'] ) : ( new Admin\Tools\Migrations() )->replace_site_stripe_iframes( $replaced_ss_content ); // Only update the widget if it's content is changed. if ( ! empty( $replaced_ss_content ) || ! empty( $replaced_ss_iframe_content ) ) { /* translators: %s - Widget name */ aawp_log( 'Site Stripe Migration', sprintf( __( 'Migration completed for Widget - %s', 'aawp' ), $widget_name ) ); $widget['content'] = ! empty( $replaced_ss_iframe_content ) ? $replaced_ss_iframe_content : $replaced_ss_content; } $updated_widget[ $key ] = $widget; }//end foreach update_option( $widget_name, $updated_widget ); } /** * Cancel all the AS actions for a group "aawp". * * @since 3.21.0 * * @return void */ public function cancel_all() { if ( class_exists( 'ActionScheduler_DBStore' ) ) { \ActionScheduler_DBStore::instance()->cancel_actions_by_group( 'aawp' ); } } } 'requires' => false, 'rating' => false, 'ratings' => false, 'downloaded' => false, 'last_updated' => false, 'added' => false, 'tags' => false, 'compatibility' => false, 'homepage' => false, 'donate_link' => false, ), ) ); if ( is_wp_error( $api ) ) { return $api; } $install = $this->install_from_api( $api ); return $install; } /** * Implements the install using Plugin_Upgrader, WP built in class. * * @param \stdClass $api Plugin installer data in object, see plugins_api(). * @return bool|\WP_Error */ protected function install_from_api( \stdClass $api ) { // Include necessary plugin functions. $installer = new \Plugin_Upgrader( new \WP_Ajax_Upgrader_Skin() ); $install = $installer->install( $api->download_link ); if ( empty( $install ) || is_wp_error( $install ) ) { return $install; } return true; } }