Last active
August 29, 2015 14:07
-
-
Save aaroneaton/718201c795182c008d0c to your computer and use it in GitHub Desktop.
Creating the theme class
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 | |
class Optin_Monster_Lightbox_Theme_Sample extends Optin_Monster_Theme { | |
/** | |
* Path to the file. | |
* | |
* @var string | |
*/ | |
public $file = __FILE__; | |
/** | |
* Slug of the theme. | |
* | |
* @var string | |
*/ | |
public $theme = 'sample'; | |
/** | |
* The width of the image for the optin. | |
* This is only needed if the theme has an image | |
* | |
* @var int | |
*/ | |
public $img_width = 230; | |
/** | |
* The height of the image for the optin. | |
* This is only needed if the theme has an image | |
* | |
* @var int | |
*/ | |
public $img_height = 195; | |
/** | |
* Primary class constructor. | |
* | |
* The constructor must invoke the parent constructor | |
* | |
* @param int $optin_id The optin ID to target. | |
*/ | |
public function __construct( $optin_id ) { | |
// Construct via the parent object. | |
parent::__construct( $optin_id ); | |
// Set the optin type. | |
$this->type = $this->meta['type']; | |
} | |
/** | |
* Retrieval method for getting the styles for a theme. | |
* | |
* @return string A string of concatenated CSS for the theme. | |
*/ | |
public function get_styles() { | |
// All of the theme styles will go here | |
} | |
/** | |
* Retrieval method for getting the HTML output for a theme. | |
* | |
* @return string A string of HTML for the theme. | |
*/ | |
public function get_html() { | |
// The optin HTML is returned by this method | |
} | |
/** | |
* Retrieval method for getting any custom JS for a theme. | |
* | |
* @return string A string of JS for the theme. | |
*/ | |
public function get_js() { | |
} | |
/** | |
* Outputs the filters needed to register controls for the OptinMonster | |
* preview customizer and save the fields registered. | |
*/ | |
public function controls() { | |
add_filter( 'optin_monster_panel_design_fields', array( $this, 'design_fields' ), 10, 2 ); | |
add_filter( 'optin_monster_panel_input_fields', array( $this, 'input_fields' ), 10, 2 ); | |
add_filter( 'optin_monster_save_optin', array( $this, 'save_controls' ), 10, 4 ); | |
} | |
/** | |
* Outputs the design controls for the theme. | |
* | |
* Each field should be added to the $fields array with a unique slug. | |
* | |
* @param array $fields Array of design fields. | |
* @param object $instance The Edit UI instance. | |
* @return array $fields Amended array of design fields. | |
*/ | |
public function design_fields( $fields, $instance ) { | |
// We'll create the design fields here (background color, border color, etc.) | |
} | |
/** | |
* Outputs the fields controls for the theme. | |
* | |
* @param array $fields Array of input fields. | |
* @param object $instance The Edit UI instance. | |
* @return array $fields Amended array of input fields. | |
*/ | |
public function input_fields( $fields, $instance ) { | |
// Our input fields (name, email & submit) go here | |
} | |
/** | |
* Saves the meta fields for the optin controls. | |
* | |
* @param array $meta The meta key "_om_meta" with all of its data. | |
* @param int $optin_id The optin ID to target. | |
* @param array $fields The post fields under the key "optin_monster". | |
* @param array $post_data All of the $_POST contents generated when saving. | |
* @return array $meta Amended array of meta to be saved. | |
*/ | |
public function save_controls( $meta, $optin_id, $fields, $post_data ) { | |
// Now we'll get everything saved properly. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment