documents->get( $page_id ); $settings = []; if ( $document ) { $elements = \Elementor\Plugin::instance()->documents->get( $page_id )->get_elements_data(); $widget_data = $this->find_element_recursive( $elements, $widget_id ); if ( $widget_data ) { $widget = \Elementor\Plugin::instance()->elements_manager->create_element_instance( $widget_data ); if ( $widget ) { $settings = $widget->get_settings_for_display(); } } } return $settings; } /** * Find element recursively * * @since 0.0.1 */ public function find_element_recursive( $elements, $form_id ) { foreach ( $elements as $element ) { if ( $form_id === $element[ 'id' ] ) { return $element; } if ( !empty( $element[ 'elements' ] ) ) { $element = $this->find_element_recursive( $element[ 'elements' ], $form_id ); if ( $element ) { return $element; } } } return false; } public function titleToSnake($text, $divider = '_') { // Handle null or empty values to prevent deprecated warnings. if ( null === $text || '' === $text ) { return 'n_a'; } $text = (string) $text; $text = preg_replace('~[^\pL\d]+~u', $divider, $text); $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); $text = preg_replace('~[^-\w]+~', '', $text); $text = trim($text, $divider); $text = preg_replace('~-+~', $divider, $text); $text = strtolower($text); if (empty($text)) { return 'n_a'; } return $text; } public function arrayToString($array, $separator = ', ', $extraString = ''){ $string = rtrim( implode($separator, $array ), $separator ) ; if($extraString) { $string .= $extraString; } return $string; } public function transaction_statuses_with_type(){ $statuses = [ 'completed' => [ 'statuses' => [ 'paid', 'Completed', 'completed', // Stripe's own status for a fully-discounted / $0 Checkout // Session (100% coupon or sale, free trial). The payment // IS settled - there was simply nothing to charge - so it // must classify as completed, not fall through to the // unknown-status default. See Helper::get_type_by_transaction_status(). 'no_payment_required', ], 'color' => '#0ECA86', ], 'processing' => [ 'statuses' => [ 'pending', 'Pending', NULL, ], 'color' => '#FFDA15', ], 'refunded' => [ 'statuses' => [ 'refunded', ], 'color' => '#FF0202', ], 'unpaid' => [ 'statuses' => [ 'unpaid', ], 'color' => '#999', ], 'all' => [ 'statuses' => [ 'paid', 'Completed', 'completed', 'no_payment_required', 'unpaid', 'refunded', 'pending', 'Pending', NULL, ], 'color' => '#999', ], ]; return $statuses; } public function transaction_statuses_with_type_v2(){ $statuses = [ 'completed' => [ 'statuses' => [ 'paid', 'Completed', 'completed', 'success', // See the v1 note: a $0 Stripe session settles as // 'no_payment_required'. Every status bucket is also a // `status IN (...)` filter in DB::get_transactions(), so a // status missing from BOTH 'completed' and 'incomplete' // is invisible under either tab while still showing on // the unfiltered list - which is exactly how a paid $0 // order looked like a stray "Incomplete" row. 'no_payment_required', ], 'color' => '#0ECA86', ], 'incomplete' => [ 'statuses' => [ 'pending', 'Pending', 'unpaid', 'incomplete', 'Incomplete', NULL, ], 'color' => '#FFDA15', ], 'refunded' => [ 'statuses' => [ 'refunded', ], 'color' => '#FF0202', ], 'all' => [ 'statuses' => [ 'paid', 'Completed', 'completed', 'no_payment_required', 'unpaid', 'refunded', 'pending', 'Pending', 'success', 'incomplete', 'Incomplete', NULL, ], 'color' => '#999', ], ]; return $statuses; } public function get_type_by_transaction_status($status = '', $version = 'v1'){ if('v1' === $version){ $statuses = $this->transaction_statuses_with_type(); } else { $statuses = $this->transaction_statuses_with_type_v2(); } $status_type = ''; if(!empty($status)){ foreach($statuses as $type => $statuses_and_color){ if(in_array($status, $statuses_and_color['statuses'])){ $status_type = $type; break; } } } if($status === '' || $status === NULL){ $status_type = 'incomplete'; } return $status_type; } public function get_color_by_transaction_status($status = '', $version = 'v1'){ if('v1' === $version){ $statuses = $this->transaction_statuses_with_type(); } else { $statuses = $this->transaction_statuses_with_type_v2(); } $color = '#999'; if(!empty($status)){ foreach($statuses as $type => $statuses_and_color){ if(in_array($status, $statuses_and_color['statuses'])){ $color = $statuses_and_color['color']; break; } } } if($status === '' || $status === NULL){ $color = '#FFDA15'; //incomplete } return $color; } public function get_color_by_transaction_type($status_type = '', $version = 'v1'){ if('v1' === $version){ $statuses = $this->transaction_statuses_with_type(); } else { $statuses = $this->transaction_statuses_with_type_v2(); } $color = ''; if(!empty($status_type)){ foreach($statuses as $type => $statuses_and_color){ if($type == $status_type){ $color = $statuses_and_color['color']; break; } } } return $color; } public function get_statuses_by_transaction_type($status_type = 'all', $version = 'v1'){ if('v1' === $version){ $statuses = $this->transaction_statuses_with_type(); } else { $statuses = $this->transaction_statuses_with_type_v2(); } $transaction_statuses = []; if(!empty($status_type)){ foreach($statuses as $type => $statuses_and_color){ if($type == $status_type){ $transaction_statuses = $statuses_and_color['statuses']; break; } } } return $transaction_statuses; } public function get_transaction_types($version = 'v1'){ if('v1' === $version){ $statuses = $this->transaction_statuses_with_type(); } else { $statuses = $this->transaction_statuses_with_type_v2(); } $statuses_types = array_keys($statuses); return $statuses_types; } /** * Get interval text for recurring and split payment * * @since 1.3.0 */ public function get_interval_text( $interval = '' ){ $interval_text = ''; switch( $interval ) { case 'day': $interval_text = 'Daily'; break; case 'month': case 'year': $interval_text = $interval . 'ly'; break; default : $interval_text = ! empty( $interval ) ? "Per " . esc_html( $interval ) : ""; break; } return esc_html( ucfirst( $interval_text ) ); } /** * Output the page header, compatible with both classic and block themes. * * Block themes don't use get_header() — they rely on block template parts. * We detect this with wp_is_block_theme() and render the header template * part via do_blocks() so it appears correctly on CPT single pages that * bypass the theme's block templates. * * @param string $block_header Pre-rendered header markup from do_blocks() (block themes only). * @return void */ public static function render_header( string $block_header = '' ): void { if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) { ?> > > last_query ); echo wp_kses_post( $wpdb->last_result ); echo wp_kses_post( $wpdb->last_error ); } echo '
';
        print_r( $data ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
        if ( ! $print_only ) {
            wp_die( 'Printed!' );
        }
    }
}