Skip to content

Commit

Permalink
Some fixes #69
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Jul 30, 2018
1 parent 1ca5be4 commit 6ab03b9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 74 deletions.
26 changes: 12 additions & 14 deletions classes/class.rest-api.php
Expand Up @@ -33,25 +33,23 @@ public function register_rest_api_routes(){
public function get_all_posts() {
$all_posts = get_posts(
array(
'post_type' => array('post','page'),
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // all posts
'post_type' => array( 'post', 'page' ),
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // all posts
)
);
if( $all_posts ){

if ( $all_posts ) {
$source = array();
foreach( $all_posts as $k => $post ) {
$source[$k]['id'] = $post->ID;
$source[$k]['text'] = $post->ID.' - '.$post->post_title;

foreach ( $all_posts as $k => $post ) {
$source[ $k ]['id'] = $post->ID;
$source[ $k ]['text'] = $post->ID . ' - ' . $post->post_title;
}
}

return $source;
}
}

new Smart_Custom_Fields_Rest_API();
82 changes: 38 additions & 44 deletions classes/controller/class.settings.php
Expand Up @@ -44,19 +44,18 @@ public function __construct() {
),
);
}

/**
* Get Current Admin Color Scheme
*
* @return object
*/
public function admin_color_scheme(){
protected function admin_color_scheme() {
global $_wp_admin_css_colors;

$user_admin_color_scheme = get_user_option('admin_color');

$colors_obj = $_wp_admin_css_colors[$user_admin_color_scheme];


$user_admin_color_scheme = get_user_option( 'admin_color' );
$colors_obj = $_wp_admin_css_colors[ $user_admin_color_scheme ];

return $colors_obj;
}

Expand All @@ -65,29 +64,24 @@ public function admin_color_scheme(){
*
*/
public function admin_inline_css(){

$colors = $this->admin_color_scheme()->colors;
$icon_colors = $this->admin_color_scheme()->icon_colors;
?>
<style>
#smart-cf-meta-box-condition-post .selectivity-load-more.highlight,
#smart-cf-meta-box-condition-post .selectivity-result-item.highlight {
background-color: <?php echo esc_html( $colors[2] ); ?>;
}

//print_r($colors);
//print_r($icon_colors);

$output = '<style>';

$output .=
'#smart-cf-meta-box-condition-post .selectivity-load-more.highlight,
#smart-cf-meta-box-condition-post .selectivity-result-item.highlight { background-color:' . $colors[2] . '; }';

$output .=
'.smart-cf-group .smart-cf-group-repeat label .ios-ui-select.checked,
#smart-cf-meta-box-condition-post .ios-ui-select.checked,
#smart-cf-meta-box-condition-profile .ios-ui-select.checked,
#smart-cf-meta-box-condition-taxonomy .ios-ui-select.checked,
#smart-cf-meta-box-condition-options-page .ios-ui-select.checked { box-shadow: inset 0 0 0 36px ' . $colors[2] . '; }';

$output .= '</style>';

echo $output;
.smart-cf-group .smart-cf-group-repeat label .ios-ui-select.checked,
#smart-cf-meta-box-condition-post .ios-ui-select.checked,
#smart-cf-meta-box-condition-profile .ios-ui-select.checked,
#smart-cf-meta-box-condition-taxonomy .ios-ui-select.checked,
#smart-cf-meta-box-condition-options-page .ios-ui-select.checked {
box-shadow: inset 0 0 0 36px <?php echo esc_html( $colors[2] ); ?>;
}
</style>
<?php
}

/**
Expand All @@ -102,14 +96,14 @@ public function admin_enqueue_scripts() {
array(),
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../css/settings.css' ) )
);

wp_enqueue_style(
SCF_Config::PREFIX . 'selectivity',
plugins_url( SCF_Config::NAME ) . '/libs/selectivity-3.1.0/selectivity-jquery.min.css',
array(),
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../libs/selectivity-3.1.0/selectivity-jquery.min.css' ) )
);

wp_enqueue_style(
SCF_Config::PREFIX . 'ios-checkbox',
plugins_url( SCF_Config::NAME ) . '/libs/iosCheckbox/iosCheckbox.min.css',
Expand All @@ -124,15 +118,15 @@ public function admin_enqueue_scripts() {
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings.js' ) ),
true
);

wp_enqueue_script(
SCF_Config::PREFIX . 'selectivity',
plugins_url( SCF_Config::NAME ) . '/libs/selectivity-3.1.0/selectivity-jquery.min.js',
array(),
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../libs/selectivity-3.1.0/selectivity-jquery.min.js' ) ),
true
);

wp_enqueue_script(
SCF_Config::PREFIX . 'ios-checkbox',
plugins_url( SCF_Config::NAME ) . '/libs/iosCheckbox/iosCheckbox.min.js',
Expand All @@ -152,7 +146,7 @@ public function admin_enqueue_scripts() {
wp_enqueue_script( 'jquery-ui-sortable' );
do_action( SCF_Config::PREFIX . 'after-settings-enqueue-scripts' );
}

/**
* Adding meta boxes
*/
Expand Down Expand Up @@ -318,35 +312,35 @@ public function display_meta_box_condition_post() {
esc_html__( 'Post Types', 'smart-custom-fields' ),
$post_type_field
);

$condition_post_ids = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'condition-post-ids', true );

// get all posts saved
$saved_posts = explode(',',$condition_post_ids);
if( $saved_posts ){
$saved_posts = explode( ',', $condition_post_ids );

if ( $saved_posts ) {
$saved = array();

foreach( $saved_posts as $k => $post_id ) {
$saved[$k]['id'] = $post_id;
$saved[$k]['text'] = $post_id; //$post_id . ' - ' . get_the_title($post_id);
$saved[ $k ]['id'] = $post_id;
$saved[ $k ]['text'] = $post_id; //$post_id . ' - ' . get_the_title($post_id);
}
}

// create variable js with posting IDs to use in post search results
printf(
'<script type="text/javascript">smart_cf_saved_posts = %s; </script>',
'<script type="text/javascript">smart_cf_saved_posts = %s;</script>',
json_encode( array_values( $saved ) )
);

// create div to use with jquery plugin "selectivity"
// https://github.com/arendjr/selectivity
// https://github.com/arendjr/selectivity
printf(
'<p><b>%s</b><div id="%s" class="selectivity-input"></div></p>',
esc_html__( 'Post or Page Ids', 'smart-custom-fields' ),
esc_attr( SCF_Config::PREFIX . 'autocomplete-condition-post' )
);

// create input hidden with the IDS of saved posts
printf(
'<input type="hidden" name="%s" value="%s"/>',
Expand Down
30 changes: 15 additions & 15 deletions css/settings.css
Expand Up @@ -75,7 +75,7 @@
position: relative;
top: -2px;
}
@media (max-width:750px){
@media (max-width:750px) {
.smart-cf-group .smart-cf-group-name {
max-width:79%;
}
Expand Down Expand Up @@ -199,16 +199,16 @@
}

#smart-cf-meta-box-condition-post .selectivity-multiple-input {
box-shadow:none;
box-shadow: none;
}

#smart-cf-meta-box-condition-post .selectivity-multiple-selected-item {
margin-right:5px;
margin-right: 5px;
}

#smart-cf-meta-box-condition-post .selectivity-multiple-selected-item-remove {
font-weight:bold;
color:#fff;
font-weight: bold;
color: #fff;
}

#smart-cf-meta-box-condition-post .selectivity-multiple-input-container {
Expand All @@ -218,28 +218,28 @@
color: #32373c;
outline: 0;
transition: 50ms border-color ease-in-out;
border-radius:0px;
border-radius: 0;
}

#smart-cf-meta-box-condition-post .selectivity-dropdown,
#smart-cf-meta-box-condition-post .selectivity-result-item:first-child,
#smart-cf-meta-box-condition-post .selectivity-load-more,
#smart-cf-meta-box-condition-post .selectivity-result-item:last-child,
#smart-cf-meta-box-condition-post .selectivity-result-children:last-child .selectivity-result-item:last-child {
border-radius:0px;
border-radius: 0;
}

.smart-cf-group .smart-cf-group-repeat label .ios-ui-select,
#smart-cf-meta-box-condition-post .ios-ui-select,
#smart-cf-meta-box-condition-profile .ios-ui-select,
#smart-cf-meta-box-condition-taxonomy .ios-ui-select,
#smart-cf-meta-box-condition-options-page .ios-ui-select {
height:18px;
width:32px;
margin-bottom:-5px;
position:relative;
background:#ddd;
box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
height: 18px;
width: 32px;
margin-bottom: -5px;
position: relative;
background: #ddd;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07);

}

Expand All @@ -248,8 +248,8 @@
#smart-cf-meta-box-condition-profile .ios-ui-select .inner,
#smart-cf-meta-box-condition-taxonomy .ios-ui-select .inner,
#smart-cf-meta-box-condition-options-page .ios-ui-select .inner {
width:12px;
height:12px;
width: 12px;
height: 12px;
}

.smart-cf-group .smart-cf-group-repeat label .ios-ui-select.checked .inner,
Expand Down
4 changes: 3 additions & 1 deletion smart-custom-fields.php
Expand Up @@ -20,9 +20,11 @@ class Smart_Custom_Fields {
*/
public function __construct() {
require_once plugin_dir_path( __FILE__ ) . 'classes/class.config.php';
require_once plugin_dir_path( __FILE__ ) . 'classes/class.rest-api.php';
require_once plugin_dir_path( __FILE__ ) . 'classes/class.rest-api.php';
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );

new Smart_Custom_Fields_Rest_API();
}

/**
Expand Down

0 comments on commit 6ab03b9

Please sign in to comment.