' . __( 'Settings', 'woocommerce-custom-thank-you-pages' ) . '' ), $links ); return $links; } add_action( 'plugin_action_links_' . plugin_basename( WOOCOMMERCE_CUSTOM_THANK_YOU_PAGES_FILE ), 'WooCommerce_Custom_Thank_You_Pages\Admin\plugin_action_links' ); /** * Enqueue admin scripts. * * Enqueue the required javascripts and stylesheets. * * @since 1.0.0 * * @param $hook */ function enqueue_scripts( $hook ) { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_register_script( 'custom-thank-you-pages', plugins_url( 'assets/admin/js/woocommerce-custom-thank-you-pages' . $suffix . '.js', \WooCommerce_Custom_Thank_You_Pages\WooCommerce_Custom_Thank_You_Pages()->file ), array( 'jquery' ), \WooCommerce_Custom_Thank_You_Pages\WooCommerce_Custom_Thank_You_Pages()->version, true ); wp_localize_script( 'custom-thank-you-pages', 'wcctyp', array( 'nonce' => wp_create_nonce( 'wcctyp-ajax-nonce' ), 'i18n' => array( 'noChange' => __( '— No Change —' ), ), ) ); if ( get_post_type() == 'product' || ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-settings' && isset( $_GET['section'] ) && $_GET['section'] == 'thank-you-pages' ) ) { wp_enqueue_script( 'select2' ); wp_enqueue_script( 'custom-thank-you-pages' ); } } add_action( 'admin_enqueue_scripts', 'WooCommerce_Custom_Thank_You_Pages\Admin\enqueue_scripts' ); /** * Inline scripts. * * Print inline scripts for this plugin. It only adds them on the required pages. * Inline scripts have been chosen as they are too small to warrant extra GET requests. * * @since 1.0.0 */ function admin_footer_scripts() { if ( get_post_type() !== 'product' && ( isset( $_GET['page'] ) && $_GET['page'] !== 'wc-settings' ) || ( isset( $_GET['section'] ) && $_GET['section'] !== 'thank-you-pages' ) ) { return; } ?>

get_id() ); } } add_action( 'woocommerce_product_quick_edit_save', 'WooCommerce_Custom_Thank_You_Pages\Admin\quick_edit_save', 10 ); /** * Save bulk edit. * * Save the custom bulk edit field. * * @since 1.0.0 * * @param \WC_Product $product Product object. */ function bulk_edit_save( $product ) { if ( $_REQUEST['custom_thank_you_page'] != 'no_change' ) { $product->update_meta_data( '_custom_thank_you_page', wc_clean( $_REQUEST['custom_thank_you_page'] ) ); } if ( ! empty( $_REQUEST['custom_thank_you_page_priority'] ) ) { $product->update_meta_data( '_custom_thank_you_page_priority', absint( $_REQUEST['custom_thank_you_page_priority'] ) ); } $product->save(); } add_action( 'woocommerce_product_bulk_edit_save', 'WooCommerce_Custom_Thank_You_Pages\Admin\bulk_edit_save', 10 );