Current Path : /storage/v11800/testtest/public_html/wp-content/plugins/12-April-fastrr-checkout-plugin/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/testtest/public_html/wp-content/plugins/12-April-fastrr-checkout-plugin/FastrrCheckout.php |
<?php
/*
add_action( 'admin_menu', 'testprefix_add_admin_menu' );
add_action( 'admin_init', 'testprefix_settings_init' );
function testprefix_add_admin_menu( ) {
//add_menu_page( 'testtheme', 'testtheme', 'manage_options', 'testtheme', 'testprefix_options_page' );
add_menu_page(
'testtheme', // page_title
'testtheme', // menu_title
'manage_options', // capability
'testtheme', // menu_slug
'testprefix_options_page' // function
);
}
function testprefix_settings_init( ) {
register_setting( 'pluginPage', 'testprefix_settings' );
add_settings_section(
'testprefix_pluginPage_section',
__( 'Your section description', 'testdomain' ),
'testprefix_settings_section_callback',
'pluginPage'
);
add_settings_field(
'testprefix_text_field_0',
__( 'Settings field description', 'testdomain' ),
'testprefix_text_field_0_render',
'pluginPage',
'testprefix_pluginPage_section'
);
add_settings_field(
'testprefix_checkbox_field_1',
__( 'Settings field description', 'testdomain' ),
'testprefix_checkbox_field_1_render',
'pluginPage',
'testprefix_pluginPage_section'
);
add_settings_field(
'testprefix_radio_field_2',
__( 'Settings field description', 'testdomain' ),
'testprefix_radio_field_2_render',
'pluginPage',
'testprefix_pluginPage_section'
);
add_settings_field(
'testprefix_textarea_field_3',
__( 'Settings field description', 'testdomain' ),
'testprefix_textarea_field_3_render',
'pluginPage',
'testprefix_pluginPage_section'
);
add_settings_field(
'testprefix_select_field_4',
__( 'Settings field description', 'testdomain' ),
'testprefix_select_field_4_render',
'pluginPage',
'testprefix_pluginPage_section'
);
}
function testprefix_text_field_0_render( ) {
$options = get_option( 'testprefix_settings' );
?>
<input type='text' name='testprefix_settings[testprefix_text_field_0]' value='<?php echo $options['testprefix_text_field_0']; ?>'>
<?php
}
function testprefix_checkbox_field_1_render( ) {
$options = get_option( 'testprefix_settings' );
?>
<input type='checkbox' name='testprefix_settings[testprefix_checkbox_field_1]' <?php checked( $options['testprefix_checkbox_field_1'], 1 ); ?> value='1'>
<?php
}
function testprefix_radio_field_2_render( ) {
$options = get_option( 'testprefix_settings' );
?>
<input type='radio' name='testprefix_settings[testprefix_radio_field_2]' <?php checked( $options['testprefix_radio_field_2'], 1 ); ?> value='1'>Yes
<input type='radio' name='testprefix_settings[testprefix_radio_field_2]' <?php checked( $options['testprefix_radio_field_2'], 0 ); ?> value='0'>No
<?php
}
function testprefix_textarea_field_3_render( ) {
$options = get_option( 'testprefix_settings' );
?>
<textarea cols='40' rows='5' name='testprefix_settings[testprefix_textarea_field_3]'>
<?php echo $options['testprefix_textarea_field_3']; ?>
</textarea>
<?php
}
function testprefix_select_field_4_render( ) {
$options = get_option( 'testprefix_settings' );
?>
<select name='testprefix_settings[testprefix_select_field_4]'>
<option value='1' <?php selected( $options['testprefix_select_field_4'], 1 ); ?>>Option 1</option>
<option value='2' <?php selected( $options['testprefix_select_field_4'], 2 ); ?>>Option 2</option>
</select>
<?php
}
function testprefix_settings_section_callback( ) {
echo __( 'This section description', 'testdomain' );
}
function testprefix_options_page( ) {
?>
<form action="options.php" method='post'>
<h2>testtheme</h2>
<?php
settings_fields( 'pluginPage' );
do_settings_sections( 'pluginPage' );
submit_button();
?>
</form>
<?php
}
// new
/**
* Generated by the WordPress Option Page generator
* at http://jeremyhixon.com/wp-tools/option-page/
*/
//echo $current_rel_uri = add_query_arg( NULL, NULL );
//echo $current_uri = home_url( add_query_arg( NULL, NULL ) );
if (!defined('ABSPATH')) {
exit; // exit if directly accessed
}
class FastrrCheckout {
private $fastrr_checkout_options;
private $email;
public function __construct() {
add_action( 'admin_menu', array( $this, 'fastrr_checkout_add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'fastrr_checkout_page_init' ) );
// Handle links on plugin page
}
public function fastrr_checkout_add_plugin_page() {
add_menu_page(
'Fastrr checkout', // page_title
'Fastrr checkout', // menu_title
'manage_options', // capability
'fastrr-checkout', // menu_slug
array( $this, 'fastrr_checkout_create_admin_page' ) // function
);
}
public function fastrr_checkout_create_admin_page() {
$this->email = pickrr_Shipping_Rates_Common::get_current_user_email_id();
$this->fastrr_checkout_options = get_option( 'fastrr_checkout_option_name' ); ?>
<?php
if($this->fastrr_checkout_options === false) {
update_option( 'fastrr_checkout_option_name', $this->predefined_value() );
$this->fastrr_checkout_options = get_option( 'fastrr_checkout_option_name' );
}
?>
<div class="wrap">
<h2>Fastrr checkout</h2>
<p>Fastrr checkout style configration.</p>
<?php settings_errors();
?>
<form action="options.php" method='post' enctype="multipart/form-data">
<?php
//options.php
settings_fields( 'fastrr_checkout_option_group' );
do_settings_sections( 'fastrr-checkout-admin' );
$attributes = array( 'id' => 'fastrr_checkout_option_save_changes' );
submit_button ( 'Save changes', 'primary', 'submit', true, $attributes );
//submit_button();
?>
</form>
</div>
<?php }
public function fastrr_checkout_page_init() {
register_setting(
'fastrr_checkout_option_group', // option_group
'fastrr_checkout_option_name', // option_name
array( $this, 'fastrr_checkout_sanitize' ) // sanitize_callback
);
add_settings_section(
'fastrr_checkout_setting_section', // id, String for use in the 'id' attribute of tags
'', // title, Title of the section
array( $this, 'fastrr_checkout_section_info' ), // callback, Function that fills the section with the desired content
'fastrr-checkout-admin' // page, The menu page on which to display this section.
);
add_settings_field(
'email_id', // id
'Email Id', // title
array( $this, 'email_id_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
add_settings_field(
'integration_id', // id
'Fastrr activate Key', // title
array( $this, 'integration_id_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
// add_settings_field(
// 'fastrr_checkout_display_name', // id
// 'Default button name', // title
// array( $this, 'fastrr_checkout_display_name_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section' // section
// );
add_settings_field(
'fastrr_checkout_template_name', // id
'Template Name', // title
array( $this, 'fastrr_checkout_template_name_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
add_settings_field(
'fastrr_checkout_display_disc_value', // id
'Discount Value', // title
array( $this, 'fastrr_checkout_display_disc_value_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
add_settings_field(
'fastrr_checkout_display_discount_type', // id
'Discount Type', // title
array( $this, 'fastrr_checkout_display_discount_type_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
add_settings_field(
'proceed_to_checkout_button_enabled', // id
'Proceed to checkout button enable', // title
array( $this, 'proceed_to_checkout_button_enabled_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
// Product Page
add_settings_section(
'fastrr_checkout_setting_section_product_page', // id
'Product Page', // title
array( $this, 'fastrr_checkout_section_info' ), // callback
'fastrr-checkout-admin' // page
);
add_settings_field(
'fastrr_enable_in_product_page_enabled', // id
'Fastrr button enable/disable', // title
array( $this, 'fastrr_enable_in_product_page_enabled_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section_product_page' // section
);
// add_settings_field(
// 'fastrr_enable_in_product_page_style_width', // id
// 'Button width', // title
// array( $this, 'fastrr_enable_in_product_page_style_width_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_product_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_product_page_style_background_color', // id
// 'Button background color', // title
// array( $this, 'fastrr_enable_in_product_page_style_background_color_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_product_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_product_page_style_border', // id
// 'Button border', // title
// array( $this, 'fastrr_enable_in_product_page_style_border_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_product_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_product_page_style', // id
// 'Button extra css', // title
// array( $this, 'fastrr_enable_in_product_page_style_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_product_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_product_page_img_style', // id
// 'Img tag css', // title
// array( $this, 'fastrr_enable_in_product_page_img_style_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_product_page' // section
// );
// Cart page
add_settings_section(
'fastrr_checkout_setting_section_cart_page', // id
'Cart Page', // title
array( $this, 'fastrr_checkout_section_info' ), // callback
'fastrr-checkout-admin' // page
);
add_settings_field(
'fastrr_enable_in_cart_page_enabled', // id
'Fastrr enable in cart page', // title
array( $this, 'fastrr_enable_in_cart_page_enabled_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section_cart_page' // section
);
add_settings_section(
'fastrr_checkout_setting_mini_cart', // id
'Mini Cart', // title
array( $this, 'fastrr_checkout_section_info' ), // callback
'fastrr-checkout-admin' // page
);
add_settings_field(
'fastrr_enable_in_mini_cart', // id
'Fastrr enable in Mini cart', // title
array( $this, 'fastrr_enable_in_mini_cart_field_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_mini_cart' // section
);
add_settings_field(
'mini_cart_sort_code', // id
'Mini cart Sort Code', // title
array( $this, 'mini_cart_sort_code_field_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_mini_cart' // section
);
add_settings_section(
'fastrr_checkout_plugin_mode', // id
'Plugin Mode', // title
array( $this, 'fastrr_checkout_section_info' ), // callback
'fastrr-checkout-admin' // page
);
add_settings_field(
'fastrr_enable_in_prod_mode', // id
'Production Mode', // title
array( $this, 'fastrr_enable_in_prod_mode_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_plugin_mode' // section
);
// add_settings_field(
// 'mini_cart_sort_code', // id
// 'Mini cart Sort Code', // title
// array( $this, 'mini_cart_sort_code_field_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_mini_cart' // section
// );
///// Cart page button css start
// add_settings_field(
// 'fastrr_enable_in_cart_page_style_width', // id
// 'Button width', // title
// array( $this, 'fastrr_enable_in_cart_page_style_width_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_cart_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_cart_page_style_background_color', // id
// 'Button background color', // title
// array( $this, 'fastrr_enable_in_cart_page_style_background_color_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_cart_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_cart_page_style_border', // id
// 'Button border', // title
// array( $this, 'fastrr_enable_in_cart_page_style_border_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_cart_page' // section
// );
// add_settings_field(
// 'fastrr_enable_in_cart_page_style', // id
// 'Button extra css', // title
// array( $this, 'fastrr_enable_in_cart_page_style_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_cart_page' // section
// );
///// Cart page button css end
// add_settings_field(
// 'fastrr_enable_in_cart_page_img_style', // id
// 'Fastrr img tag css in product page', // title
// array( $this, 'fastrr_enable_in_cart_page_img_style_callback' ), // callback
// 'fastrr-checkout-admin', // page
// 'fastrr_checkout_setting_section_cart_page' // section
// );
/*
add_settings_field(
'select_theam_10', // id
'select theam', // title
array( $this, 'select_theam_10_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
*/
/*
add_settings_field(
'on_off_11', // id
'Select theme', // title
array( $this, 'on_off_11_callback' ), // callback
'fastrr-checkout-admin', // page
'fastrr_checkout_setting_section' // section
);
*/
}
public function fastrr_checkout_sanitize($input) {
$sanitary_values = array();
if ( isset( $input['fastrr_checkout_display_name'] ) ) {
$sanitary_values['fastrr_checkout_display_name'] = sanitize_text_field( $input['fastrr_checkout_display_name'] );
}
if ( isset( $input['fastrr_checkout_display_discount_type'] ) ) {
$sanitary_values['fastrr_checkout_display_discount_type'] = sanitize_text_field( $input['fastrr_checkout_display_discount_type'] );
}
if ( isset( $input['fastrr_checkout_template_name'] ) ) {
$sanitary_values['fastrr_checkout_template_name'] = sanitize_text_field( $input['fastrr_checkout_template_name'] );
}
if ( isset( $input['fastrr_checkout_display_disc_value'] ) ) {
$sanitary_values['fastrr_checkout_display_disc_value'] = sanitize_text_field( $input['fastrr_checkout_display_disc_value'] );
}
if ( isset( $input['fastrr_checkout_display_template'] ) ) {
$sanitary_values['fastrr_checkout_display_template'] = sanitize_text_field( $input['fastrr_checkout_display_template'] );
}
if ( isset( $input['proceed_to_checkout_button_enabled'] ) ) {
$sanitary_values['proceed_to_checkout_button_enabled'] = $input['proceed_to_checkout_button_enabled'];
}else{
$sanitary_values['proceed_to_checkout_button_enabled'] = sanitize_text_field( "no");
}
//////// product page
if ( isset( $input['fastrr_enable_in_product_page_enabled'] ) ) {
$sanitary_values['fastrr_enable_in_product_page_enabled'] = $input['fastrr_enable_in_product_page_enabled'];
}else{
$sanitary_values['fastrr_enable_in_product_page_enabled'] = sanitize_text_field( "no");
}
if ( isset( $input['fastrr_enable_in_mini_cart'] ) ) {
$sanitary_values['fastrr_enable_in_mini_cart'] = $input['fastrr_enable_in_mini_cart'];
}else{
$sanitary_values['fastrr_enable_in_mini_cart'] = sanitize_text_field( "no");
}
if ( isset( $input['mini_cart_sort_code'] ) ) {
$sanitary_values['mini_cart_sort_code'] = $input['mini_cart_sort_code'];
}
if ( isset( $input['fastrr_enable_in_prod_mode'] ) ) {
$sanitary_values['fastrr_enable_in_prod_mode'] = $input['fastrr_enable_in_prod_mode'];
}else{
$sanitary_values['fastrr_enable_in_prod_mode'] = sanitize_text_field( "no");
}
// if ( isset( $input['fastrr_enable_in_product_page_style'] ) ) {
// $sanitary_values['fastrr_enable_in_product_page_style'] = sanitize_text_field( $input['fastrr_enable_in_product_page_style'] );
// }
// if ( isset( $input['fastrr_enable_in_product_page_style_width'] ) ) {
// $sanitary_values['fastrr_enable_in_product_page_style_width'] = sanitize_text_field( $input['fastrr_enable_in_product_page_style_width'] );
// }
// if ( isset( $input['fastrr_enable_in_product_page_style_background_color'] ) ) {
// $sanitary_values['fastrr_enable_in_product_page_style_background_color'] = sanitize_text_field( $input['fastrr_enable_in_product_page_style_background_color'] );
// }
// if ( isset( $input['fastrr_enable_in_product_page_style_border'] ) ) {
// $sanitary_values['fastrr_enable_in_product_page_style_border'] = sanitize_text_field( $input['fastrr_enable_in_product_page_style_border'] );
// }
// if ( isset( $input['fastrr_enable_in_product_page_img_style'] ) ) {
// $sanitary_values['fastrr_enable_in_product_page_img_style'] = sanitize_text_field( $input['fastrr_enable_in_product_page_img_style'] );
// }
//////// cart page
if ( isset( $input['fastrr_enable_in_cart_page_enabled'] ) ) {
$sanitary_values['fastrr_enable_in_cart_page_enabled'] = $input['fastrr_enable_in_cart_page_enabled'];
}else{
$sanitary_values['fastrr_enable_in_cart_page_enabled'] = sanitize_text_field( "no");
}
//////// cart page button css start
// if ( isset( $input['fastrr_enable_in_cart_page_style'] ) ) {
// $sanitary_values['fastrr_enable_in_cart_page_style'] = sanitize_text_field( $input['fastrr_enable_in_cart_page_style'] );
// }
// if ( isset( $input['fastrr_enable_in_cart_page_style_width'] ) ) {
// $sanitary_values['fastrr_enable_in_cart_page_style_width'] = sanitize_text_field( $input['fastrr_enable_in_cart_page_style_width'] );
// }
// if ( isset( $input['fastrr_enable_in_cart_page_style_background_color'] ) ) {
// $sanitary_values['fastrr_enable_in_cart_page_style_background_color'] = sanitize_text_field( $input['fastrr_enable_in_cart_page_style_background_color'] );
// }
// if ( isset( $input['fastrr_enable_in_cart_page_style_border'] ) ) {
// $sanitary_values['fastrr_enable_in_cart_page_style_border'] = sanitize_text_field( $input['fastrr_enable_in_cart_page_style_border'] );
// }
//////// cart page button css end
// if ( isset( $input['fastrr_enable_in_cart_page_img_style'] ) ) {
// $sanitary_values['fastrr_enable_in_cart_page_img_style'] = sanitize_text_field( $input['fastrr_enable_in_cart_page_img_style'] );
// }
if ( isset( $input['email_id'] ) ) {
$sanitary_values['email_id'] = sanitize_text_field( $input['email_id'] );
}else{
$sanitary_values['email_id'] = $this->email;
}
if ( isset( $input['integration_id'] ) ) {
$sanitary_values['integration_id'] = sanitize_text_field( $input['integration_id'] );
}
if ( isset( $input['select_theam_10'] ) ) {
$sanitary_values['select_theam_10'] = $input['select_theam_10'];
}else{
$sanitary_values['select_theam_10'] = "light";
}
if ( isset( $input['on_off_11'] ) ) {
$sanitary_values['on_off_11'] = $input['on_off_11'];
}else{
$sanitary_values['on_off_11'] = "on";
}
return $sanitary_values;
}
public function fastrr_checkout_section_info() {
printf(
'<hr>'
);
}
public function fastrr_checkout_template_name_callback() {
printf(
'<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_checkout_template_name]" id="fastrr_checkout_template_name" value="%s">',
isset( $this->fastrr_checkout_options['fastrr_checkout_template_name'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_checkout_template_name']) : 'Checkout'
);
}
public function fastrr_checkout_display_name_callback() {
printf(
'<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_checkout_display_name]" id="fastrr_checkout_display_name" value="%s">',
isset( $this->fastrr_checkout_options['fastrr_checkout_display_name'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_checkout_display_name']) : 'Checkout'
);
}
public function fastrr_checkout_display_disc_value_callback() {
printf(
'<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_checkout_display_disc_value]" id="fastrr_checkout_display_disc_value" value="%s">',
isset( $this->fastrr_checkout_options['fastrr_checkout_display_disc_value'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_checkout_display_disc_value']) : ''
);
}
public function fastrr_checkout_display_discount_type_callback() {
printf(
'<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_checkout_display_discount_type]" id="fastrr_checkout_display_discount_type" value="%s">',
isset( $this->fastrr_checkout_options['fastrr_checkout_display_discount_type'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_checkout_display_discount_type']) : ''
);
}
public function proceed_to_checkout_button_enabled_callback() {
printf(
'<input type="checkbox" name="fastrr_checkout_option_name[proceed_to_checkout_button_enabled]" id="proceed_to_checkout_button_enabled" value="yes" %s> <label for="proceed_to_checkout_button_enabled">Enable</label>',
( isset( $this->fastrr_checkout_options['proceed_to_checkout_button_enabled'] ) && $this->fastrr_checkout_options['proceed_to_checkout_button_enabled'] === "yes" ) ? 'checked' : ''
);
}
public function fastrr_enable_in_product_page_enabled_callback() {
printf(
'<input type="checkbox" name="fastrr_checkout_option_name[fastrr_enable_in_product_page_enabled]" id="fastrr_enable_in_product_page_enabled" value="yes" %s> <label for="fastrr_enable_in_product_page_enabled">Enable</label>',
( isset( $this->fastrr_checkout_options['fastrr_enable_in_product_page_enabled'] ) && $this->fastrr_checkout_options['fastrr_enable_in_product_page_enabled'] === 'yes' ) ? 'checked' : ''
);
}
// product page button css
// public function fastrr_enable_in_product_page_style_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_product_page_style]" id="fastrr_enable_in_product_page_style" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style']) : ''
// );
// }
// public function fastrr_enable_in_product_page_style_width_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_product_page_style_width]" id="fastrr_enable_in_product_page_style_width" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style_width'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style_width']) : '100%'
// );
// }
// public function fastrr_enable_in_product_page_style_background_color_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_product_page_style_background_color]" id="fastrr_enable_in_product_page_style_background_color" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style_background_color'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style_background_color']) : '#1064db'
// );
// }
// public function fastrr_enable_in_product_page_style_border_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_product_page_style_border]" id="fastrr_enable_in_product_page_style_border" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style_border'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_product_page_style_border']) : 'none'
// );
// }
// product page images css
// public function fastrr_enable_in_product_page_img_style_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_product_page_img_style]" id="fastrr_enable_in_product_page_img_style" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_product_page_img_style'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_product_page_img_style']) : ''
// );
// }
// fastrr cart button enable/disable
public function fastrr_enable_in_cart_page_enabled_callback() {
printf(
'<input type="checkbox" name="fastrr_checkout_option_name[fastrr_enable_in_cart_page_enabled]" id="fastrr_enable_in_cart_page_enabled" value="yes" %s> <label for="fastrr_enable_in_cart_page_enabled">Enable</label>',
( isset( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_enabled'] ) && $this->fastrr_checkout_options['fastrr_enable_in_cart_page_enabled'] === 'yes' ) ? 'checked' : ''
);
}
public function fastrr_enable_in_mini_cart_field_callback() {
printf(
'<input type="checkbox" name="fastrr_checkout_option_name[fastrr_enable_in_mini_cart]" id="fastrr_enable_in_mini_cart" value="yes" %s> <label for="fastrr_enable_in_mini_cart">Enable</label>',
( isset( $this->fastrr_checkout_options['fastrr_enable_in_mini_cart'] ) && $this->fastrr_checkout_options['fastrr_enable_in_mini_cart'] === 'yes' ) ? 'checked' : ''
);
}
public function fastrr_enable_in_prod_mode_callback() {
printf(
'<input type="checkbox" name="fastrr_checkout_option_name[fastrr_enable_in_prod_mode]" id="fastrr_enable_in_prod_mode" value="yes" %s> <label for="fastrr_enable_in_prod_mode">Enable</label>',
( isset( $this->fastrr_checkout_options['fastrr_enable_in_prod_mode'] ) && $this->fastrr_checkout_options['fastrr_enable_in_prod_mode'] === 'yes' ) ? 'checked' : ''
);
}
public function mini_cart_sort_code_field_callback() {
printf(
'<input class="regular-text" type="text" name="fastrr_checkout_option_name[mini_cart_sort_code]" id="mini_cart_sort_code" value="%s">',
isset( $this->fastrr_checkout_options['mini_cart_sort_code'] ) ? esc_attr( $this->fastrr_checkout_options['mini_cart_sort_code']) : ''
);
}
// Button css cart page
// public function fastrr_enable_in_cart_page_style_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_cart_page_style]" id="fastrr_enable_in_cart_page_style" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style']) : ''
// );
// }
// public function fastrr_enable_in_cart_page_style_width_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_cart_page_style_width]" id="fastrr_enable_in_cart_page_style_width" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style_width'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style_width']) : '100%'
// );
// }
// public function fastrr_enable_in_cart_page_style_background_color_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_cart_page_style_background_color]" id="fastrr_enable_in_cart_page_style_background_color" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style_background_color'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style_background_color']) : '#1064db'
// );
// }
// public function fastrr_enable_in_cart_page_style_border_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_cart_page_style_border]" id="fastrr_enable_in_cart_page_style_border" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style_border'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_style_border']) : 'none'
// );
// }
// Image css cart page
// public function fastrr_enable_in_cart_page_img_style_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[fastrr_enable_in_cart_page_img_style]" id="fastrr_enable_in_cart_page_img_style" value="%s">',
// isset( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_img_style'] ) ? esc_attr( $this->fastrr_checkout_options['fastrr_enable_in_cart_page_img_style']) : ''
// );
// }
public function email_id_callback() {
// printf(
// '<input class="regular-text" type="text" name="fastrr_checkout_option_name[email_id]" id="email_id" value="%s">',
// isset( $this->fastrr_checkout_options['email_id'] ) ? esc_attr( $this->fastrr_checkout_options['email_id']) : ''
// );
printf(
'%s',
isset( $this->fastrr_checkout_options['email_id'] ) ? esc_attr( $this->fastrr_checkout_options['email_id']) : $this->email
);
}
public function integration_id_callback() {
printf(
'<input class="regular-text" type="text" name="fastrr_checkout_option_name[integration_id]" id="integration_id" value="%s">',
isset( $this->fastrr_checkout_options['integration_id'] ) ? esc_attr( $this->fastrr_checkout_options['integration_id']) : ''
);
printf(
'<button class="button button-primary" type="button" id="pickrr_reset_account_details">%s</button>',
esc_attr("Reset API Keys")
);
printf(
'<button class="button button-primary" type="button" id="pickrr_verify_account_details" >%s</button>',
esc_attr("Verify API Keys")
);
}
public function select_theam_10_callback() {
?> <select class="regular-text" name="fastrr_checkout_option_name[select_theam_10]" id="select_theam_10">
<?php $selected = (isset( $this->fastrr_checkout_options['select_theam_10'] ) && $this->fastrr_checkout_options['select_theam_10'] === 'light') ? 'selected' : '' ; ?>
<option value="light" <?php echo $selected; ?>>light</option>
<?php $selected = (isset( $this->fastrr_checkout_options['select_theam_10'] ) && $this->fastrr_checkout_options['select_theam_10'] === 'dark') ? 'selected' : '' ; ?>
<option value="dark" <?php echo $selected; ?>>dark</option>
</select> <?php
}
public function on_off_11_callback() {
?> <fieldset>
<?php $checked = ( isset( $this->fastrr_checkout_options['on_off_11'] ) && $this->fastrr_checkout_options['on_off_11'] === 'on' ) ? 'checked' : '' ; ?>
<label for="on_off_11-0"><input type="radio" name="fastrr_checkout_option_name[on_off_11]" id="on_off_11-0" value="on" <?php echo $checked; ?>> Light</label><br>
<?php $checked = ( isset( $this->fastrr_checkout_options['on_off_11'] ) && $this->fastrr_checkout_options['on_off_11'] === 'off' ) ? 'checked' : '' ; ?>
<label for="on_off_11-1"><input type="radio" name="fastrr_checkout_option_name[on_off_11]" id="on_off_11-1" value="off" <?php echo $checked; ?>> Dark</label>
</fieldset> <?php
}
public function predefined_value(){
$value = [];
$value['email_id'] = $this->email;
$value['fastrr_checkout_display_name'] = "Checkout";
$value['fastrr_checkout_template_name'] = "Buy Now";
$value['fastrr_checkout_display_disc_value'] = "";
$value['fastrr_checkout_display_discount_type'] = "";
$value['fastrr_checkout_display_template'] = "upi";
// $value['fastrr_enable_in_product_page_img_style'] = "font-weight: 600; font-size: 10px; line-height: 120%; color: #002659; display: flex; justify-content: center; align-items: center;";
// $value['fastrr_enable_in_cart_page_img_style'] = "font-weight: 600; font-size: 10px; line-height: 120%; color: #002659; display: flex; justify-content: center; align-items: center;";
$value['proceed_to_checkout_button_enabled'] = "yes";
$value['fastrr_enable_in_product_page_enabled'] = "yes";
$value['fastrr_enable_in_cart_page_enabled'] = "no";
$value['fastrr_enable_in_mini_cart'] = 'no';
$value['mini_cart_sort_code'] = '';
$value['fastrr_enable_in_prod_mode'] = 'no';
// button default css in product page
// $value['fastrr_enable_in_product_page_style_width'] = "100%";
// $value['fastrr_enable_in_product_page_style_background_color'] = '#1064db';
// $value['fastrr_enable_in_product_page_style_border'] = 'none';
// $value['fastrr_enable_in_product_page_style'] = "";
// button default css in cart page
// $value['fastrr_enable_in_cart_page_style_width'] = "100%";
// $value['fastrr_enable_in_cart_page_style_background_color'] = '#1064db';
// $value['fastrr_enable_in_cart_page_style_border'] = 'none';
// $value['fastrr_enable_in_cart_page_style'] = "";
return $value;
}
}
if ( is_admin() )
$fastrr_checkout = new FastrrCheckout();
/*
* Retrieve this value with:
* $fastrr_checkout_options = get_option( 'fastrr_checkout_option_name' ); // Array of All Options
* $fastrr_checkout_display_name = $fastrr_checkout_options['fastrr_checkout_display_name']; // Default button name
* $proceed_to_checkout_button_enabled = $fastrr_checkout_options['proceed_to_checkout_button_enabled']; // Proceed to checkout button enable
* $fastrr_enable_in_product_page_enabled = $fastrr_checkout_options['fastrr_enable_in_product_page_enabled']; // Fastrr enable in product page
* $fastrr_enable_in_product_page_style = $fastrr_checkout_options['fastrr_enable_in_product_page_style']; // Fastrr button css in product page
* $fastrr_enable_in_product_page_img_style = $fastrr_checkout_options['fastrr_enable_in_product_page_img_style']; // Fastrr img tag css in product page
* $fastrr_enable_in_cart_page_enabled = $fastrr_checkout_options['fastrr_enable_in_cart_page_enabled']; // Fastrr enable in cart page
* $fastrr_enable_in_cart_page_style = $fastrr_checkout_options['fastrr_enable_in_cart_page_style']; // Fastrr button css in cart page
* $fastrr_enable_in_cart_page_img_style = $fastrr_checkout_options['fastrr_enable_in_cart_page_img_style']; // Fastrr img tag css in product page
* $email_id = $fastrr_checkout_options['email_id']; // Email Id
* $integration_id = $fastrr_checkout_options['integration_id']; // Fastrr activate Key
*/
$img = plugin_dir_url( __FILE__ ).'includes/images/icon/tick_png.png';
if (isset($_GET['page']) && $_GET['page']=='fastrr-checkout') {
?>
<script type="text/javascript">
window.addEventListener('load', function () {
jQuery('#integration_id').attr('style', "pointer-events: none; background-color:#88888869");
jQuery('#faster_Error').remove(); // To avoid multiple times
jQuery('#pickrr_verify_account_details').hide();
jQuery('#pickrr_reset_account_details').hide();
var integrationId = jQuery('#integration_id').val();
if (integrationId != undefined && integrationId.length == 0) {
jQuery('#pickrr_verify_account_details').show();
jQuery('#integration_id').attr('style', "pointer-events: all;");
jQuery('#integration_id').focus();
jQuery('#fastrr_checkout_option_save_changes').prop("disabled", true);
}else{
jQuery('#pickrr_reset_account_details').show();
}
jQuery("#pickrr_reset_account_details").click(function () {
jQuery('#integration_id').val('');
jQuery('#integration_id').attr('style', "pointer-events: all;");
jQuery('#integration_id').focus();
jQuery('#pickrr_reset_account_details').hide();
jQuery('#pickrr_verify_account_details').show();
});
jQuery("#pickrr_verify_account_details").click(function () {
var integrationId = jQuery('#integration_id').val();
var token_lenght = 36;
if ((integrationId != undefined && integrationId.length == 0) || (integrationId.length != token_lenght)) {
jQuery('#integration_id').attr('style', "border-radius: 5px; border:#FF0000 1px solid;");
jQuery('#integration_id').focus();
//jQuery('#faster_Error').val("Enter your integration id with pickrr");
if (integrationId.length != token_lenght) {
alert("Pls Enter valid integration Id.");
}
return false;
}
var token = 'ACCESS_TOKEN:' + '<?php echo pickrr_ACCESS_TOKEN; ?>';
var data = {};
data.id = integrationId;
jQuery.ajax({
url: "<?php echo pickrr_WC_ACCOUNT_REGISTER_ENDPOINT;?>",
data: JSON.stringify(data),
method: 'POST',
contentType: 'application/json',
}).done(function (response) {
console.log(response, 'Done Response');
if (response.status != 1) {
//jQuery(this).prop("disabled", false);
alert("Invalid key");
jQuery('#integration_id').focus();
jQuery('#integration_id').attr('style', "border-radius: 5px; border:#FF0000 1px solid;");
} else if (response.status == true) {
jQuery("#integration_id").val(response.data.secret_key);
jQuery('#fastrr_checkout_option_save_changes').show();
jQuery('#pickrr_verify_account_details').prop("disabled", true);
jQuery('#pickrr_verify_account_details').hide();
jQuery("#pickrr_reset_account_details").before('<img id="theImg" style="width: 3%;" src="<?php echo $img; ?>" />');
jQuery('#integration_id').attr('style', "border-radius: 5px; border:#2ecc71 1px solid; pointer-events: none;");
jQuery('#fastrr_checkout_option_save_changes').prop("disabled", false);
}
}).fail(function (result) {
jQuery('#pickrr_verify_account_details').prop("disabled", false);
console.log(result, 'Response Fail');
console.log(result.responseJSON, 'Response responseJSON Fail');
if (result.responseJSON != undefined && result.responseJSON.message != undefined) {
alert(result.responseJSON.message);
}
});
});
});
</script>
<?php } ?>