Skip to content

Commit

Permalink
Merge pull request #214 from abaicus/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
abaicus authored Mar 4, 2018
2 parents ce8c0f3 + 4c3c32d commit 88b9992
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 89 deletions.
103 changes: 80 additions & 23 deletions core/app/helpers/class-orbit-fox-render-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class Orbit_Fox_Render_Helper {
*
* @since 1.0.0
* @access public
*
* @param string $name The name of the partial w/o '-tpl.php'.
* @param array $args Optional. An associative array with name and value to be
* passed to the partial.
* passed to the partial.
*
* @return string
*/
public function get_partial( $name = '', $args = array() ) {
Expand All @@ -39,6 +41,7 @@ public function get_partial( $name = '', $args = array() ) {
if ( file_exists( $file ) ) {
include $file;
}

return ob_get_clean();
}

Expand All @@ -47,9 +50,11 @@ public function get_partial( $name = '', $args = array() ) {
*
* @since 1.0.0
* @access public
*
* @param string $name The name of the partial w/o '-page.php'.
* @param array $args Optional. An associative array with name and value to be
* passed to the view.
* passed to the view.
*
* @return string
*/
public function get_view( $name = '', $args = array() ) {
Expand All @@ -63,6 +68,7 @@ public function get_view( $name = '', $args = array() ) {
if ( file_exists( $file ) ) {
include $file;
}

return ob_get_clean();
}

Expand All @@ -71,7 +77,9 @@ public function get_view( $name = '', $args = array() ) {
*
* @since 1.0.0
* @access private
* @param array $option The specific defaults array.
*
* @param array $option The specific defaults array.
*
* @return array
*/
private function sanitize_option( $option ) {
Expand All @@ -98,14 +106,17 @@ private function sanitize_option( $option ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function set_field_value( $option = array() ) {
$field_value = $option['default'];
if ( isset( $option['value'] ) && $option['value'] != '' ) {
$field_value = $option['value'];
}

return $field_value;
}

Expand All @@ -114,15 +125,18 @@ private function set_field_value( $option = array() ) {
*
* @since 1.0.0
* @access private
*
* @param string $element_id The option id field.
* @param string $title The option title field.
*
* @return string
*/
private function get_title( $element_id, $title ) {
$display_title = '';
if ( $title ) {
$display_title = '<label class="form-label" for="' . $element_id . '">' . $title . '</label>';
}

return $display_title;
}

Expand All @@ -131,14 +145,17 @@ private function get_title( $element_id, $title ) {
*
* @since 1.0.0
* @access private
*
* @param string $description The option description field.
*
* @return string
*/
private function get_description( $description ) {
$display_description = '';
if ( $description ) {
$display_description = '<p><small>' . $description . '</small></p>';
}

return $display_description;
}

Expand All @@ -147,8 +164,10 @@ private function get_description( $description ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option array.
* @param string $element The element we want to wrap.
*
* @return string
*/
private function wrap_element( $option, $element ) {
Expand All @@ -167,43 +186,47 @@ private function wrap_element( $option, $element ) {

return '
' . $before_wrap . '
<div class="form-group ' . $option['class'] . '">
' . $title . '
' . $element . '
' . $description . '
</div>
' . $after_wrap . '
';
<div class="form-group ' . $option['class'] . '">
' . $title . '
' . $element . '
' . $description . '
</div>
' . $after_wrap . '
';
}

/**
* DRY method to generate checkbox or radio field types
*
* @since 1.0.0
* @access private
*
* @param string $type The field type ( checkbox | radio ).
* @param string $field_value The field value.
* @param string $checked The checked flag.
* @param string $label The option label.
* @param array $option The option from the module.
*
* @return string
*/
private function generate_check_type( $type = 'radio', $field_value, $checked, $label, $option = array() ) {
return '
<label class="form-' . $type . ' ' . $option['class'] . '">
<input type="' . $type . '" name="' . $option['name'] . '" value="' . $field_value . '" ' . $checked . ' />
<i class="form-icon"></i> ' . $label . '
</label>
';
<label class="form-' . $type . ' ' . $option['class'] . '">
<input type="' . $type . '" name="' . $option['name'] . '" value="' . $field_value . '" ' . $checked . ' />
<i class="form-icon"></i> ' . $label . '
</label>
';
}

/**
* Render an input text field.
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
* @param bool $is_email Render an email input instead of text.
*
* @return mixed
*/
private function field_text( $option = array(), $is_email = false ) {
Expand All @@ -224,7 +247,9 @@ private function field_text( $option = array(), $is_email = false ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function field_textarea( $option = array() ) {
Expand All @@ -240,7 +265,9 @@ private function field_textarea( $option = array() ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function field_select( $option = array() ) {
Expand All @@ -254,9 +281,9 @@ private function field_select( $option = array() ) {
$select_options .= '<option value="' . $value . '" ' . $is_selected . '>' . $label . '</option>';
}
$field = '
<select class="form-select ' . $option['class'] . '" id="' . $option['id'] . '" name="' . $option['name'] . '" placeholder="' . $option['placeholder'] . '">
' . $select_options . '
</select>';
<select class="form-select ' . $option['class'] . '" id="' . $option['id'] . '" name="' . $option['name'] . '" placeholder="' . $option['placeholder'] . '">
' . $select_options . '
</select>';
$field = $this->wrap_element( $option, $field );

return $field;
Expand All @@ -267,7 +294,9 @@ private function field_select( $option = array() ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function field_radio( $option = array() ) {
Expand All @@ -290,7 +319,9 @@ private function field_radio( $option = array() ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function field_checkbox( $option = array() ) {
Expand All @@ -310,7 +341,9 @@ private function field_checkbox( $option = array() ) {
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function field_toggle( $option = array() ) {
Expand All @@ -320,10 +353,31 @@ private function field_toggle( $option = array() ) {
$checked = 'checked';
}
$field = '
<label class="form-switch ' . $option['class'] . '">
<input type="checkbox" name="' . $option['name'] . '" value="1" ' . $checked . ' />
<i class="form-icon"></i> ' . $option['label'] . '
</label>';
<label class="form-switch ' . $option['class'] . '">
<input type="checkbox" name="' . $option['name'] . '" value="1" ' . $checked . ' />
<i class="form-icon"></i> ' . $option['label'] . '
</label>';
$field = $this->wrap_element( $option, $field );

return $field;
}

/**
* Render a toggle field.
*
* @since 1.0.0
* @access private
*
* @param array $option The option from the module.
*
* @return mixed
*/
private function field_link( $option = array() ) {
$field = '
<a id="' . esc_attr( $option['link-id'] ) . '" class="' . esc_attr( $option['link-class'] ) . '" href="' . esc_url( $option['url'] ) . '">' .
wp_kses_post( $option['text'] )
. '</a>';

$field = $this->wrap_element( $option, $field );

return $field;
Expand All @@ -334,6 +388,7 @@ private function field_toggle( $option = array() ) {
*
* @since 1.0.0
* @access public
*
* @param array $option The option from the module..
*
* @return mixed
Expand Down Expand Up @@ -365,7 +420,9 @@ public function render_option( $option = array() ) {
break;
case 'custom':
return apply_filters( 'obfx_custom_control_' . $option['id'], '' );

break;
case 'link':
return $this->field_link( $option );
break;
default:
return __( 'No option found for provided type', 'themeisle-companion' );
Expand Down
2 changes: 1 addition & 1 deletion core/assets/css/orbit-fox-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Extends Spectre.css Library
*/
/*
Version: 2.4.2
Version: 2.4.3
*/

/* Document
Expand Down
2 changes: 1 addition & 1 deletion core/includes/class-orbit-fox.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct() {

$this->plugin_name = 'orbit-fox';

$this->version = '2.4.2';
$this->version = '2.4.3';

$this->load_dependencies();
$this->set_locale();
Expand Down
Loading

0 comments on commit 88b9992

Please sign in to comment.