Changeset 1233647
- Timestamp:
- 08/29/2015 11:02:55 AM (11 years ago)
- Location:
- pixterme/trunk
- Files:
-
- 2 edited
-
admin.php (modified) (2 diffs)
-
pixter-me.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pixterme/trunk/admin.php
r1213398 r1233647 47 47 "default" => "img" 48 48 ), 49 array( 50 "type" => "cond", 51 "name" => __("Show on pages (shows all if off)", 'pixter-me'), 52 "desc" => __("When opened, you must select on which pages you want to show pixter-me", 'pixter-me'), 53 "id" => "show_pages", 54 "fields" => array( 55 array( 56 "type" => "posts", 57 "name" => __("Show button on the following pages only", 'pixter-me'), 58 "id" => "pages", 59 "options" => array('args' => array('post_type' => 'page', 'numberposts' => -1), 'type' => 'checkbox_list'), 60 'class' => 'no-toggle', 61 ), 62 ), 63 ), 64 array( 65 "type" => "cond", 66 "name" => __("Show on posts by categories (shows all if off)", 'pixter-me'), 67 "desc" => __("When opened, you must select on which posts categories you want to show pixter-me", 'pixter-me'), 68 "id" => "show_posts", 69 "fields" => array( 70 array( 71 "type" => "taxonomy", 72 "name" => __("Show button on the following posts categories", 'pixter-me'), 73 "id" => "taxonomies", 74 "options" => array('taxonomy' => 'category', 'args' => array('hide_empty' => false), 'type' => 'checkbox_list'), 75 'class' => 'no-toggle', 76 ), 77 ), 78 ), 49 79 ); 80 81 /* Support custom post types not working because the loading timing. TBD 82 $custom_post_type = get_post_types(array('public' => true, '_builtin' => false)); 83 if (!empty($custom_post_type)) 84 $fields[] = array( 85 "type" => "cond", 86 "name" => __("Show on post types", 'pixter-me'), 87 "desc" => __("By default will show on all post types", 'pixter-me'), 88 "id" => "show_post_types", 89 "fields" => array( 90 array( 91 "type" => "checkbox_list", 92 "name" => __("Show button on the following custom post types", 'pixter-me'), 93 "id" => "custom_post_type", 94 "desc" => __("Will show only on selected custom post types.", 'pixter-me'), 95 "options" => $custom_post_type, 96 'class' => 'no-toggle', 97 ), 98 ), 99 ); 100 */ 50 101 51 102 $pixter_me_user = get_option('pixter_me_user'); … … 196 247 $logo = plugins_url( 'logo.png', __FILE__ ); 197 248 echo " 198 <style> .wp-admin #wpfooter { position: static; } </style> 249 <style> 250 .wp-admin #wpfooter { position: static; } 251 .conditinal_container { margin: 0 0 15px 5%; } 252 </style> 199 253 <div style='margin: 20px 10px 0'> 200 254 <a href='http://www.pixter-media.com' target='_blank'><img src='$logo'></a> -
pixterme/trunk/pixter-me.php
r1213398 r1233647 23 23 function plugins_loaded_pixter_me() 24 24 { 25 // embed the javascript file that makes the AJAX request 26 wp_enqueue_script( 'pixter-me-script', plugin_dir_url( __FILE__ ) . 'script.js', array( 'jquery' ) ); 27 wp_localize_script( 'pixter-me-script', 'pixterAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); 28 25 if (is_admin()) 26 { 27 // embed the javascript file that makes the AJAX request 28 wp_enqueue_script( 'pixter-me-script', plugin_dir_url( __FILE__ ) . 'script.js', array( 'jquery' ), false, true ); 29 wp_localize_script( 'pixter-me-script', 'pixterAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); 30 } 29 31 load_plugin_textdomain( 'pixter-me', false, dirname( plugin_basename( __FILE__ )).'/languages' ); 30 32 } … … 43 45 register_activation_hook( __FILE__, 'pixter_me_activate' ); 44 46 45 function pixter_me_init() 47 // function pixter_me_init() 48 // { 49 // // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) 50 // // wp_enqueue_script( 'pixter-me-global', 'http://ddd.rrr.com/x.js', array(), '0.1', true ); 51 // } 52 // add_action( 'init', 'pixter_me_init'); 53 54 function show_pixter() 46 55 { 47 // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) 48 // wp_enqueue_script( 'pixter-me-global', 'http://ddd.rrr.com/x.js', array(), '0.1', true ); 56 global $post; 57 58 $options = (object)get_option('pixter_me_options'); 59 $post_type = get_post_type(); 60 switch ($post_type) 61 { 62 case 'page': 63 if (!empty($options->show_pages) && $options->show_pages['enabled'] == 'on') 64 { 65 $pages = $options->show_pages['pages']; 66 if (empty($pages) || !is_array($pages) || !in_array($post->ID, $pages)) 67 return false; 68 } 69 break; 70 case 'post': 71 if (!empty($options->show_posts) && $options->show_posts['enabled'] == 'on') 72 { 73 $taxonomies = $options->show_posts['taxonomies']; 74 if (empty($taxonomies)) 75 return false; 76 77 $categories = wp_get_post_categories($post->ID, array('fields' => 'slugs')); 78 foreach ($categories as $cat) 79 if (in_array($cat, $taxonomies)) 80 return true; 81 82 return false; 83 } 84 break; 85 default: 86 break; 87 } 88 return true; 49 89 } 50 add_action( 'init', 'pixter_me_init');51 90 52 91 function pixter_me_inline_script() 53 92 { 54 $apiKey = get_option('pixter_me_user'); 55 if (!empty($apiKey) && !wp_script_is( 'pixter_me_inline', 'done' ) )93 $apiKey = get_option('pixter_me_user'); 94 if (!empty($apiKey) && !wp_script_is( 'pixter_me_inline', 'done' ) && show_pixter()) 56 95 { 57 96 $options = (object)get_option('pixter_me_options'); 97 58 98 $button_text = $options->button_text; 59 99 $button_bg_color = $options->button_bg_color; … … 67 107 case 'bottom-left': $cssPos = "left: 5px; top: auto!important; bottom: 5px;"; break; 68 108 case 'bottom-right': $cssPos = "left: auto!important; right: 5px; top: auto!important; bottom: 5px;"; break; 69 } 70 109 } 110 71 111 */ 72 112 $selector = $options->selector; … … 80 120 "selectors":"$selector", "minHeight":150, "minWidth":150, "position":"top-left", 81 121 "text":"$button_text", "textColor":"$button_text_color", "buttonColor":"$button_bg_color" 82 }); 122 }); 83 123 } 84 124 </script> … … 88 128 global $wp_scripts; 89 129 $wp_scripts->done[] = 'pixter_me_inline'; 90 } 91 130 } 131 92 132 } 93 133 add_action( 'wp_footer', 'pixter_me_inline_script', 99999 );
Note: See TracChangeset
for help on using the changeset viewer.