-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'new-version-development'
- Loading branch information
Showing
20 changed files
with
1,987 additions
and
321 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
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,125 @@ | ||
<?php | ||
|
||
if ( ! defined( 'ABSPATH' ) ) exit; | ||
|
||
class CUWS_Admin_API { | ||
|
||
/** | ||
* Generate HTML for displaying fields | ||
* @param array $field Field data | ||
* @param boolean $echo Whether to echo the field HTML or return it | ||
* @return void | ||
* @source: //github.com/hlashbrooke/WordPress-Plugin-Template/ | ||
* @since v2.0.0 | ||
*/ | ||
public function display_field ( $data = array(), $post = false, $echo = true ) { | ||
|
||
// Get field info | ||
if ( isset( $data['field'] ) ) { | ||
$field = $data['field']; | ||
} else { | ||
$field = $data; | ||
} | ||
|
||
// Check for prefix on option name | ||
$option_name = ''; | ||
if ( isset( $data['prefix'] ) ) { | ||
$option_name = $data['prefix']; | ||
} | ||
|
||
// Get saved data | ||
$data = ''; | ||
if ( $post ) { | ||
|
||
// Get saved field data | ||
$option_name .= $field['id']; | ||
$option = get_post_meta( $post->ID, $field['id'], true ); | ||
|
||
// Get data to display in field | ||
if ( isset( $option ) ) { | ||
$data = $option; | ||
} | ||
|
||
} else { | ||
|
||
// Get saved option | ||
$option_name .= $field['id']; | ||
$option = get_option( $option_name ); | ||
|
||
// Get data to display in field | ||
if ( isset( $option ) ) { | ||
$data = $option; | ||
} | ||
|
||
} | ||
|
||
// Show default data if no option saved and default is supplied | ||
if ( $data === false && isset( $field['default'] ) ) { | ||
$data = $field['default']; | ||
} elseif ( $data === false ) { | ||
$data = ''; | ||
} | ||
|
||
$html = ''; | ||
|
||
switch( $field['type'] ) { | ||
|
||
case 'checkbox': | ||
$checked = ''; | ||
if ( $data && 'on' == $data ) { | ||
$checked = 'checked="checked"'; | ||
} | ||
$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . esc_attr( $field['type'] ) . '" name="' . esc_attr( $option_name ) . '" ' . $checked . '/>' . "\n"; | ||
break; | ||
|
||
case 'checkbox_multi': | ||
foreach ( $field['options'] as $k => $v ) { | ||
$checked = false; | ||
if ( in_array( $k, $data ) ) { | ||
$checked = true; | ||
} | ||
$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '" class="checkbox_multi"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $option_name ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" /> ' . $v . '</label> '; | ||
} | ||
break; | ||
|
||
case 'radio': | ||
foreach ( $field['options'] as $k => $v ) { | ||
$checked = false; | ||
if ( $k == $data ) { | ||
$checked = true; | ||
} | ||
$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $option_name ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" /> ' . $v . '</label> '; | ||
} | ||
break; | ||
|
||
} | ||
|
||
switch( $field['type'] ) { | ||
|
||
case 'checkbox_multi': | ||
case 'radio': | ||
$html .= '<br/><span class="description">' . $field['description'] . '</span>'; | ||
break; | ||
|
||
default: | ||
if ( ! $post ) { | ||
$html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n"; | ||
} | ||
|
||
$html .= '<span class="description">' . $field['description'] . '</span>' . "\n"; | ||
|
||
if ( ! $post ) { | ||
$html .= '</label>' . "\n"; | ||
} | ||
break; | ||
} | ||
|
||
if ( ! $echo ) { | ||
return $html; | ||
} | ||
|
||
echo $html; | ||
|
||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,59 @@ | ||
/** | ||
* All of the CSS for the admin-specific functionality is included in this file. | ||
* @since v2.0.0 | ||
*/ | ||
|
||
.seo_page_cuws_settings .wrap > h2 { | ||
background-image: url("../images/so-icon.png"); | ||
background-position: 0 0; | ||
background-repeat: no-repeat; | ||
background-size: 32px auto; | ||
display: block; | ||
min-height: 32px; | ||
padding-left: 40px !important; | ||
padding-top: 2px !important; | ||
} | ||
.seo_page_cuws_settings .wrap > p { | ||
font-size: 16px; | ||
} | ||
.seo_page_cuws_settings .wrap > form span.description { | ||
font-size: 14px; | ||
} | ||
.rate-this-plugin { | ||
color: #0074A2; | ||
font-style: italic; | ||
font-size: 16px; | ||
} | ||
.support, | ||
.translate { | ||
font-size: 16px; | ||
} | ||
.author.postbox { | ||
max-width: 500px; | ||
} | ||
.author.postbox .hndle { | ||
border-bottom: 1px solid #DDD; | ||
margin-bottom: 0; | ||
padding: 5px; | ||
} | ||
.author.postbox .inside { | ||
display: block; | ||
margin: 0; | ||
overflow: hidden; | ||
} | ||
.author.postbox .inside .top { | ||
min-height: 90px; | ||
} | ||
.author.postbox .inside > .top > .author-image { | ||
border: 1px solid #DFDFDF; | ||
float: left; | ||
margin-right: 10px; | ||
padding: 3px; | ||
} | ||
.author.postbox .inside > ul { | ||
clear: both; | ||
} | ||
.author.postbox .inside li { | ||
float: left; | ||
width: 50%; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.