-
-
Save DannyOutlaw/27c445e2caf63f70c85f to your computer and use it in GitHub Desktop.
OTO Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The plugin bootstrap file | |
* | |
* This file is read by WordPress to generate the plugin information in the plugin | |
* admin area. This file also includes all of the dependencies used by the plugin, | |
* registers the activation and deactivation functions, and defines a function | |
* that starts the plugin. | |
* | |
* @link http://example.com | |
* @since 1.0.0 | |
* @package Plugin_Name | |
* | |
* @wordpress-plugin | |
* Plugin Name: WordPress Plugin Boilerplate | |
* Plugin URI: http://example.com/plugin-name-uri/ | |
* Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area. | |
* Version: 1.0.0 | |
* Author: Your Name or Your Company | |
* Author URI: http://example.com/ | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
* Text Domain: plugin-name | |
* Domain Path: /languages | |
*/ | |
// If this file is called directly, abort. | |
if ( ! defined( 'WPINC' ) ) { | |
die; | |
} | |
/** | |
* The code that runs during plugin activation. | |
* This action is documented in includes/class-plugin-name-activator.php | |
*/ | |
function activate_plugin_name() { | |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-activator.php'; | |
Plugin_Name_Activator::activate(); | |
} | |
/** | |
* The code that runs during plugin deactivation. | |
* This action is documented in includes/class-plugin-name-deactivator.php | |
*/ | |
function deactivate_plugin_name() { | |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-deactivator.php'; | |
Plugin_Name_Deactivator::deactivate(); | |
} | |
register_activation_hook( __FILE__, 'activate_plugin_name' ); | |
register_deactivation_hook( __FILE__, 'deactivate_plugin_name' ); | |
/** | |
* The core plugin class that is used to define internationalization, | |
* admin-specific hooks, and public-facing site hooks. | |
*/ | |
require plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name.php'; | |
/** | |
* Begins execution of the plugin. | |
* | |
* Since everything within the plugin is registered via hooks, | |
* then kicking off the plugin from this point in the file does | |
* not affect the page life cycle. | |
* | |
* @since 1.0.0 | |
*/ | |
function one_time_offer() { | |
?> | |
<div id="oto-div"> | |
<form> | |
<input id="oto" type="checkbox" name="oto" value="oto" onClick="location.href='<?php echo get_stylesheet_directory_uri(); ?>/checkout?edd_action=add_to_cart&download_id= <?php echo get_theme_mod( 'textarea_field_id' ); ?>&edd_options[price_id]=2'">Buy OTO New $50<br> | |
</form> | |
</div> | |
<?php | |
} | |
add_action( 'edd_purchase_form_before_submit', 'one_time_offer' ); | |
add_filter( 'body_class','oto_classes' ); | |
function oto_classes( $classes ) { | |
$classes[] = 'oto'; | |
return $classes; | |
} | |
function prefix_customizer_register( $wp_customize ) { | |
$wp_customize->add_panel( 'panel_id', array( | |
'priority' => 10, | |
'capability' => 'edit_theme_options', | |
'theme_supports' => '', | |
'title' => __( 'Example Panel', 'textdomain' ), | |
'description' => __( 'Description of what this panel does.', 'textdomain' ), | |
) ); | |
$wp_customize->add_section( 'section_id', array( | |
'priority' => 10, | |
'capability' => 'edit_theme_options', | |
'theme_supports' => '', | |
'title' => __( 'Example Section', 'textdomain' ), | |
'description' => '', | |
'panel' => 'panel_id', | |
) ); | |
$wp_customize->add_setting( 'url_field_id', array( | |
'default' => '', | |
'type' => 'theme_mod', | |
'capability' => 'edit_theme_options', | |
'transport' => '', | |
'sanitize_callback' => 'esc_url', | |
) ); | |
$wp_customize->add_control( 'url_field_id', array( | |
'type' => 'url', | |
'priority' => 10, | |
'section' => 'section_id', | |
'label' => __( 'URL Field', 'textdomain' ), | |
'description' => '', | |
) ); | |
$wp_customize->add_setting( 'email_field_id', array( | |
'default' => '', | |
'type' => 'theme_mod', | |
'capability' => 'edit_theme_options', | |
'transport' => '', | |
'sanitize_callback' => 'sanitize_email', | |
) ); | |
$wp_customize->add_control( 'email_field_id', array( | |
'type' => 'email', | |
'priority' => 10, | |
'section' => 'section_id', | |
'label' => __( 'Email Field', 'textdomain' ), | |
'description' => '', | |
) ); | |
$wp_customize->add_setting( 'password_field_id', array( | |
'default' => '', | |
'type' => 'theme_mod', | |
'capability' => 'edit_theme_options', | |
'transport' => '', | |
'sanitize_callback' => 'sanitize_text_field', | |
) ); | |
$wp_customize->add_control( 'password_field_id', array( | |
'type' => 'password', | |
'priority' => 10, | |
'section' => 'section_id', | |
'label' => __( 'Password Field', 'textdomain' ), | |
'description' => '', | |
) ); | |
$wp_customize->add_setting( 'textarea_field_id', array( | |
'default' => '', | |
'type' => 'theme_mod', | |
'capability' => 'edit_theme_options', | |
'transport' => '', | |
'sanitize_callback' => 'esc_textarea', | |
) ); | |
$wp_customize->add_control( 'textarea_field_id', array( | |
'type' => 'textarea', | |
'priority' => 10, | |
'section' => 'section_id', | |
'label' => __( 'Textarea Field', 'textdomain' ), | |
'description' => '', | |
) ); | |
$wp_customize->add_setting( 'date_field_id', array( | |
'default' => '', | |
'type' => 'theme_mod', | |
'capability' => 'edit_theme_options', | |
'transport' => '', | |
'sanitize_callback' => '' | |
) ); | |
$wp_customize->add_control( 'date_field_id', array( | |
'type' => 'date', | |
'priority' => 10, | |
'section' => 'section_id', | |
'label' => __( 'Date Field', 'textdomain' ), | |
'description' => '', | |
) ); | |
$wp_customize->add_setting( 'range_field_id', array( | |
'default' => '', | |
'type' => 'theme_mod', | |
'capability' => 'edit_theme_options', | |
'transport' => '', | |
'sanitize_callback' => 'intval', | |
) ); | |
$wp_customize->add_control( 'range_field_id', array( | |
'type' => 'range', | |
'priority' => 10, | |
'section' => 'section_id', | |
'label' => __( 'Range Field', 'textdomain' ), | |
'description' => '', | |
'input_attrs' => array( | |
'min' => 0, | |
'max' => 100, | |
'step' => 1, | |
'class' => 'example-class', | |
'style' => 'color: #0a0', | |
), | |
) ); | |
} | |
add_action( 'customize_register', 'prefix_customizer_register' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment