芝麻web文件管理V1.00
编辑当前文件:/var/www/cognitio.in/wp-content/plugins/stripe-payments/admin/views/blocks.php
get_products_array() ); wp_localize_script( 'stripe-payments-product-block', 'aspBlockProdStr', array( 'title' => 'Stripe Payments Product', 'product' => __( 'Product', 'stripe-payments' ), 'button_only' => __( 'Show Button Only', 'stripe-payments' ), 'button_only_help' => __( 'Check this box if you just want to show the button only without any additional product info.', 'stripe-payments' ), ) ); register_block_type( 'stripe-payments/product-block', array( 'attributes' => array( 'prodId' => array( 'type' => 'string', 'default' => 0, ), 'btnOnly' => array( 'type' => 'boolean', 'default' => false, ), ), 'editor_script' => 'stripe-payments-product-block', 'render_callback' => array( $this, 'render_product_block' ), ) ); } function render_product_block( $atts ) { $prodId = ! empty( $atts['prodId'] ) ? intval( $atts['prodId'] ) : 0; if ( empty( $prodId ) ) { return '
' . __( 'Select product to view', 'stripe-payments' ) . '
'; } $sc_str = 'asp_product id="%d"'; $sc_str = sprintf( $sc_str, $prodId ); if ( ! empty( $atts['btnOnly'] ) ) { $sc_str .= ' button_only="1"'; } return do_shortcode( '[' . $sc_str . ']' ); } private function get_products_array() { $q = get_posts( array( 'post_type' => ASPMain::$products_slug, 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ) ); $prodArr = array( array( 'label' => __( '(Select product)', 'stripe-payments' ), 'value' => 0, ), ); foreach ( $q as $post ) { $title = html_entity_decode( $post->post_title ); $prodArr[] = array( 'label' => esc_attr( $title ), 'value' => $post->ID, ); } wp_reset_postdata(); return $prodArr; } } new AcceptStripePayments_Blocks();