-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ThatGerber/import-feature
Early work for import function
- Loading branch information
Showing
8 changed files
with
387 additions
and
167 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
<?php | ||
/** | ||
* Abstract class for building forms. | ||
* | ||
* Class abstraction for simple form functions. | ||
* | ||
* @link http://www.chriswgerber.com/dfp-ads | ||
* @since 0.2.0 | ||
* | ||
* @package WordPress | ||
* @subpackage DFP-Ads | ||
*/ | ||
|
||
Abstract Class DFP_Ads_Form { | ||
|
||
/** | ||
* Page Title | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
* | ||
* @var string | ||
*/ | ||
public $title; | ||
|
||
/** | ||
* String to call settings fields | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
* | ||
* @var string | ||
*/ | ||
public $settings_fields; | ||
|
||
/** | ||
* String to call settings sections | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
* | ||
* @var string | ||
*/ | ||
public $settings_sections; | ||
|
||
/** | ||
* @since 0.2.0 | ||
* @access public | ||
* | ||
* @var array | ||
*/ | ||
public $values; | ||
|
||
/** | ||
* String identifier for the options | ||
* | ||
* @since 0.2.0 | ||
* @access public | ||
* | ||
* @var string | ||
*/ | ||
public $options_str; | ||
|
||
/** | ||
* Coagulates the functions into a form on the front-end. | ||
* | ||
* Abstract | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
*/ | ||
abstract public function render_form(); | ||
|
||
/** | ||
* Adds the title to the page. | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
* | ||
* @param $title string Form Title | ||
*/ | ||
public function form_title( $title = null ) { | ||
// Takes specialized title, or uses default if empty. | ||
$title = ( $title === null ? $this->title : $title ); | ||
// Echos title | ||
echo "<h2>$title</h2>"; | ||
} | ||
|
||
/** | ||
* Creates input | ||
* | ||
* @since 0.2.0 | ||
* @access public | ||
* | ||
* @param $args array | ||
*/ | ||
public function text( $args ) { | ||
// Why is it so nested? | ||
$args = $args[0]; | ||
// Field values | ||
$id = $this->options_str . '[' . $args['id'] . ']'; | ||
$title = $args['title']; | ||
$value = ( ! isset( $this->values[ $args['id'] ] ) ? '' : $this->values[ $args['id'] ] ); | ||
?> | ||
<div> | ||
<input type="<?php echo $args->field; ?>" | ||
id="<?php _e( $id, 'dfp-ads' ); ?>" | ||
name="<?php _e( $id, 'dfp-ads' ); ?>" | ||
value="<?php _e( $value, 'dfp-ads' ); ?>" /> | ||
<?php | ||
if ( isset( $args['description'] ) ) { | ||
echo '<p><em>'. $args['description'] . '</em></p>'; | ||
} | ||
?> | ||
</div> | ||
<?php | ||
} | ||
|
||
/** | ||
* Creates Select Options for widget | ||
* | ||
* @since 0.2.0 | ||
* @access public | ||
* | ||
* @param $args Array | ||
*/ | ||
public function ads_dropdown( $args ) { | ||
// Why is it so nested? | ||
$args = $args[0]; | ||
// Field values | ||
$id = $this->options_str . '[' . $args['id'] . ']'; | ||
$title = $args['title']; | ||
$value = ( ! isset( $this->values[ $args['id'] ] ) ? '' : $this->values[ $args['id'] ] ); | ||
?> | ||
<div> | ||
<select id="<?php _e( $id, 'dfp-ads' ); ?>" name="<?php _e( $id, 'dfp-ads' ); ?>"> | ||
<?php dfp_ad_select_options( $value ); ?> | ||
</select> | ||
<?php if ( isset( $args['description'] ) ) { | ||
echo '<p><em>'. $args['description'] . '</em></p>'; | ||
} ?> | ||
</div> | ||
<?php | ||
} | ||
|
||
/** | ||
* Button Function | ||
* | ||
* Creates an HTML button. | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
* | ||
* @param $value string Value of the submit button | ||
* @param $primary bool Mark a button as a primary button | ||
*/ | ||
public function button( $value, $primary = false ) { | ||
$value = wp_strip_all_tags( $value, true ); | ||
$button_type = ($primary === false ? 'button-secondary' : 'button-primary' ) | ||
?> | ||
<input type="submit" name="submit" id="submit" class="button <?php echo $button_type; ?>" value="<?php echo $value; ?>"> | ||
<?php | ||
} | ||
|
||
/** | ||
* Simple method for accessing a submit button | ||
* | ||
* @since 0.0.1 | ||
* @access public | ||
*/ | ||
public function submit_button() { | ||
$this->button("Save Changes", true); | ||
} | ||
} |
Oops, something went wrong.