Changeset 1736194
- Timestamp:
- 09/26/2017 11:29:53 AM (8 years ago)
- Location:
- siteattention
- Files:
-
- 75 added
- 4 deleted
- 7 edited
-
tags/1.0.4 (deleted)
-
tags/1.0.5 (added)
-
tags/1.0.5/README.txt (added)
-
tags/1.0.5/admin (added)
-
tags/1.0.5/admin/class-siteattention-admin.php (added)
-
tags/1.0.5/admin/css (added)
-
tags/1.0.5/admin/css/siteattention-admin.scss (added)
-
tags/1.0.5/admin/css/siteattention-module.scss (added)
-
tags/1.0.5/admin/dist (added)
-
tags/1.0.5/admin/dist/.gitkeep (added)
-
tags/1.0.5/admin/dist/siteattention-admin.css (added)
-
tags/1.0.5/admin/dist/siteattention-admin.css.map (added)
-
tags/1.0.5/admin/dist/siteattention-admin.js (added)
-
tags/1.0.5/admin/dist/siteattention-admin.js.map (added)
-
tags/1.0.5/admin/dist/siteattention-module.css (added)
-
tags/1.0.5/admin/dist/siteattention-module.css.map (added)
-
tags/1.0.5/admin/dist/siteattention-module.js (added)
-
tags/1.0.5/admin/dist/siteattention-module.js.map (added)
-
tags/1.0.5/admin/images (added)
-
tags/1.0.5/admin/images/loading.gif (added)
-
tags/1.0.5/admin/images/logo-icon.png (added)
-
tags/1.0.5/admin/images/logo.png (added)
-
tags/1.0.5/admin/index.php (added)
-
tags/1.0.5/admin/js (added)
-
tags/1.0.5/admin/js/compiled (added)
-
tags/1.0.5/admin/js/compiled/siteattention-admin.js (added)
-
tags/1.0.5/admin/js/compiled/siteattention-admin.js.map (added)
-
tags/1.0.5/admin/js/compiled/siteattention-module.js (added)
-
tags/1.0.5/admin/js/compiled/siteattention-module.js.map (added)
-
tags/1.0.5/admin/js/siteattention-admin.js (added)
-
tags/1.0.5/admin/js/siteattention-module.js (added)
-
tags/1.0.5/admin/partials (added)
-
tags/1.0.5/admin/partials/siteattention-admin-display.php (added)
-
tags/1.0.5/admin/settings (added)
-
tags/1.0.5/admin/settings/class-siteattention-settings.php (added)
-
tags/1.0.5/includes (added)
-
tags/1.0.5/includes/class-siteattention-i18n.php (added)
-
tags/1.0.5/includes/class-siteattention-loader.php (added)
-
tags/1.0.5/includes/class-siteattention.php (added)
-
tags/1.0.5/includes/index.php (added)
-
tags/1.0.5/index.php (added)
-
tags/1.0.5/languages (added)
-
tags/1.0.5/languages/siteattention-de_DE.mo (added)
-
tags/1.0.5/languages/siteattention-de_DE.po (added)
-
tags/1.0.5/public (added)
-
tags/1.0.5/public/class-siteattention-public.php (added)
-
tags/1.0.5/public/css (added)
-
tags/1.0.5/public/css/siteattention-public.css (added)
-
tags/1.0.5/public/index.php (added)
-
tags/1.0.5/public/js (added)
-
tags/1.0.5/public/js/siteattention-public.js (added)
-
tags/1.0.5/public/partials (added)
-
tags/1.0.5/public/partials/siteattention-public-display.php (added)
-
tags/1.0.5/siteattention.php (added)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/class-siteattention-admin.php (modified) (4 diffs)
-
trunk/admin/css (added)
-
trunk/admin/css/siteattention-admin.scss (added)
-
trunk/admin/css/siteattention-module.scss (added)
-
trunk/admin/dist/.gitkeep (added)
-
trunk/admin/dist/siteattention-admin.css (modified) (1 diff)
-
trunk/admin/dist/siteattention-admin.css.map (added)
-
trunk/admin/dist/siteattention-admin.js (modified) (1 diff)
-
trunk/admin/dist/siteattention-admin.js.map (added)
-
trunk/admin/dist/siteattention-module.css (added)
-
trunk/admin/dist/siteattention-module.css.map (added)
-
trunk/admin/dist/siteattention-module.js (added)
-
trunk/admin/dist/siteattention-module.js.map (added)
-
trunk/admin/js (added)
-
trunk/admin/js/compiled (added)
-
trunk/admin/js/compiled/siteattention-admin.js (added)
-
trunk/admin/js/compiled/siteattention-admin.js.map (added)
-
trunk/admin/js/compiled/siteattention-module.js (added)
-
trunk/admin/js/compiled/siteattention-module.js.map (added)
-
trunk/admin/js/siteattention-admin.js (added)
-
trunk/admin/js/siteattention-module.js (added)
-
trunk/admin/partials/siteattention-admin-display.php (modified) (1 diff)
-
trunk/includes/class-siteattention-activator.php (deleted)
-
trunk/includes/class-siteattention-deactivator.php (deleted)
-
trunk/includes/class-siteattention.php (modified) (3 diffs)
-
trunk/public/css (added)
-
trunk/public/css/siteattention-public.css (added)
-
trunk/public/js (added)
-
trunk/public/js/siteattention-public.js (added)
-
trunk/siteattention.php (modified) (4 diffs)
-
trunk/uninstall.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
siteattention/trunk/README.txt
r1717006 r1736194 63 63 * API fix that was preventing the post from being sync from the WP posts page 64 64 65 = 1.0.5 = 66 67 * API updates & optimisations 68 * new UI for SiteAttention settings 69 65 70 == Upgrade Notice == 66 71 -
siteattention/trunk/admin/class-siteattention-admin.php
r1716976 r1736194 23 23 class SiteAttention_Admin { 24 24 25 /**26 * The ID of this plugin.27 *28 * @since 1.0.029 * @access private30 * @var string $name The ID of this plugin.31 */32 protected $name;33 34 /**35 * The version of this plugin.36 *37 * @since 1.0.038 * @access private39 * @var string $version The current version of this plugin.40 */41 protected $version;42 43 /** 44 * The WordPress options specific to SiteAttention45 *46 * @since 1.0.047 * @access private48 * @var string $version The current version of this plugin.49 */25 /** 26 * The ID of this plugin. 27 * 28 * @since 1.0.0 29 * @access private 30 * @var string $name The ID of this plugin. 31 */ 32 protected $name; 33 34 /** 35 * The version of this plugin. 36 * 37 * @since 1.0.0 38 * @access private 39 * @var string $version The current version of this plugin. 40 */ 41 protected $version; 42 43 /** 44 * The WordPress options specific to SiteAttention 45 * 46 * @since 1.0.0 47 * @access private 48 * @var string $version The current version of this plugin. 49 */ 50 50 protected $option; 51 51 52 /** 53 * Initialize the class and set its properties. 54 * 55 * @since 1.0.0 56 * @param string $name The name of this plugin. 57 * @param string $version The version of this plugin. 58 */ 59 public function __construct( $name, $version ) { 60 61 $this->name = $name; 62 $this->version = $version; 63 $this->option = get_option ( $this->name ); 64 } 65 66 /** 67 * Register the stylesheets for the admin area. 68 * 69 * @since 1.0.0 70 */ 71 public function enqueue_styles() { 72 73 /** 74 * This function is provided for demonstration purposes only. 75 * 76 * An instance of this class should be passed to the run() function 77 * defined in SiteAttention_Loader as all of the hooks are defined 78 * in that particular class. 79 * 80 * The SiteAttention_Loader will then create the relationship 81 * between the defined hooks and the functions defined in this 82 * class. 83 */ 84 85 wp_enqueue_style( $this->name, plugin_dir_url( __FILE__ ) . 'dist/siteattention-admin.css', array(), $this->version, 'all' ); 86 87 // Add Custom CSS css 88 // if ( function_exists('get_current_screen') ) { 89 // $is_edit_url = ( get_current_screen()->id === 'post' || get_current_screen()->id === 'page' ? true : false ); 90 // 91 // if ( $is_edit_url && $this->option['custom_css'] ) { 92 // wp_add_inline_style( $this->name, $this->option['custom_css'] ); 93 // } 94 // } 95 96 } 97 98 /** 99 * Register the JavaScript for the admin area. 100 * 101 * @since 1.0.0 102 */ 103 public function enqueue_scripts() { 104 105 /** 106 * This function is provided for demonstration purposes only. 107 * 108 * An instance of this class should be passed to the run() function 109 * defined in SiteAttention_Loader as all of the hooks are defined 110 * in that particular class. 111 * 112 * The SiteAttention_Loader will then create the relationship 113 * between the defined hooks and the functions defined in this 114 * class. 115 */ 116 117 // Load siteattention scripts when it is an edit page/post 118 if ( function_exists('get_current_screen') ) { 119 $is_edit_url = ( get_current_screen()->id === 'post' || get_current_screen()->id === 'page' ? true : false ); 120 121 if ( $is_edit_url ) { 122 123 // Add the plugin JS 124 wp_enqueue_script( $this->name, plugin_dir_url( __FILE__ ) . 'dist/siteattention-admin.js', array( 'jquery' ), $this->version, true ); 125 126 // SiteAttention API 127 $url = SiteAttention::URL . $this->option['key']; 128 wp_enqueue_script( 'siteattention_api', $url, array( $this->name ), null, true ); 129 130 // // Custom user JS 131 // if ( function_exists ( 'wp_add_inline_script' ) ) { 132 // wp_add_inline_script( $this->name, $this->option['custom_js'] ); 133 // } 134 // else { 135 // $this->wp_add_inline_script ( $this->name, $this->option['custom_js'] ); 136 // } 137 138 // Variables for SiteAttention.load() 139 $current_user = wp_get_current_user(); 140 wp_localize_script( $this->name, 'SiteAttentionInfo', array( 141 'user' => $current_user->user_firstname . ' ' . $current_user->user_lastname, 142 'user_id' => $current_user->ID, 143 'user_email' => $current_user->user_email, 144 'user_name' => $current_user->user_login, 145 'language' => get_locale(), 146 'key' => $this->option['key'], 147 'post_type' => get_current_screen()->id, 148 'iid' => $this->option['iid'], 149 'url' => get_permalink(), 150 'pid' => get_the_ID(), 151 'published' => get_post_status() === 'publish' 152 )); 153 } else { 154 wp_enqueue_script( $this->name, plugin_dir_url( __FILE__ ) . 'dist/siteattention-admin.js', array( 'jquery' ), $this->version, true ); 52 /** 53 * Initialize the class and set its properties. 54 * 55 * @since 1.0.0 56 * @param string $name The name of this plugin. 57 * @param string $version The version of this plugin. 58 */ 59 public function __construct( $name, $version ) { 60 61 $this->name = $name; 62 $this->version = $version; 63 $this->option = get_option($this->name); 64 } 65 66 /** 67 * Register the stylesheets for the admin area. 68 * 69 * @since 1.0.0 70 */ 71 public function enqueue_styles() { 72 73 if 74 ( // get out if not on edit page 75 !function_exists('get_current_screen') || 76 ( 77 get_current_screen()->id !== 'post' && 78 get_current_screen()->id !== 'page' 79 ) 80 ) return; 81 82 wp_enqueue_style( 83 $this->name, 84 plugin_dir_url( __FILE__ ) . 'dist/siteattention-module.css', 85 array(), 86 $this->version, 87 'all' 88 ); 89 } 90 91 /** 92 * Register the JavaScript for the admin area. 93 * 94 * @since 1.0.0 95 */ 96 public function enqueue_scripts() { 97 98 if 99 ( // get out if not on edit page 100 !function_exists('get_current_screen') || 101 ( 102 get_current_screen()->id !== 'post' && 103 get_current_screen()->id !== 'page' 104 ) 105 ) return; 106 107 // SiteAttention API 108 wp_enqueue_script( 109 $this->name . 'Api', 110 SiteAttention::URL . $this->option['key'], 111 array($this->name), 112 null, 113 true 114 ); 115 116 // SiteAttention Module 117 wp_enqueue_script( 118 $this->name, 119 plugin_dir_url( __FILE__ ) . 'dist/siteattention-module.js', 120 array('jquery'), 121 $this->version, 122 true 123 ); 124 125 $current_user = wp_get_current_user(); 126 wp_localize_script($this->name, 'SiteAttentionInfo', [ 127 'user' => $current_user->ID, //$current_user->user_firstname . ' ' . $current_user->user_lastname, 128 // 'user_id' => $current_user->ID, 129 // 'user_email' => $current_user->user_email, 130 // 'user_name' => $current_user->user_login, 131 'language' => get_locale(), 132 'key' => $this->option['key'], 133 'post_type' => get_current_screen()->id, 134 'iid' => $this->option['iid'], 135 'url' => get_permalink(), 136 'pid' => get_the_ID(), 137 'published' => get_post_status() === 'publish', 138 ]); 139 } 140 141 /** 142 * Register the Settings page. 143 * 144 * @since 1.0.0 145 */ 146 public function siteattention_admin_menu() { 147 148 add_options_page( 149 __( 'SiteAttention', $this->name), 150 __( 'SiteAttention', $this->name ), 151 'manage_options', $this->name, 152 array($this, 'display_plugin_admin_page') 153 ); 154 } 155 156 /** 157 * Plugin Settings Link on plugin page 158 * 159 * @since 1.0.0 160 * @return mixed The settings field 161 */ 162 public function add_settings_link( $links ) { 163 164 $mylinks = array( 165 '<a href="' . admin_url( "options-general.php?page=$this->name" ) . '">' . __( 'Settings', $this->name ) . '</a>', 166 ); 167 return array_merge( $links, $mylinks ); 168 } 169 170 /** 171 * Plugin Settings route adding 172 * 173 * @since 1.0.0 174 * @return mixed The settings field 175 */ 176 public function add_settings_route(){ 177 add_rewrite_endpoint('siteattention/settings', EP_ROOT); 178 flush_rewrite_rules(); 179 } 180 181 /** 182 * Callback function for the admin settings page. 183 * 184 * @since 1.0.0 185 */ 186 public function display_plugin_admin_page(){ 187 188 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/siteattention-admin-display.php'; 189 190 wp_enqueue_script( 191 $this->name, 192 plugin_dir_url( __FILE__ ) . 'dist/siteattention-admin.js', 193 array(), 194 $this->version, 195 true 196 ); 197 198 wp_localize_script($this->name,'SiteAttentionSettingsData', [ 199 'version' => SiteAttention::VERSION, 200 'cmsUrl' => '/siteattention/settings', 201 'apiUrl' => SiteAttention::URL, 202 'key' => $this->option['key'], 203 'iid' => $this->option['iid'], 204 'iname' => $this->option['iname'], 205 'locked' => $this->option['ilocked'], 206 ]); 207 } 208 209 /** 210 * Settings - Validates saved options 211 * 212 * @since 1.0.0 213 * @param array $input array of submitted plugin options 214 * @return array array of validated plugin options 215 */ 216 public function process_settings( $input ) { 217 218 // Initialize the new array that will hold the sanitize values 219 $cleaned = array(); 220 221 if(isset($input)) { 222 // Loop through the input and sanitize each of the values 223 foreach ( $input as $key => $val ) { 224 225 // dont sanitize WP stuff 226 if( $key === 'post-type' ) { 227 $cleaned[$key] = $val; 228 } 229 230 else { 231 $cleaned[$key] = sanitize_text_field($val); 232 } 155 233 } 156 234 } 157 } 158 159 /** 160 * Register the Settings page. 161 * 162 * @since 1.0.0 163 */ 164 public function siteattention_admin_menu() { 165 166 add_options_page( __( 'SiteAttention', $this->name), __( 'SiteAttention', $this->name ), 'manage_options', $this->name, array($this, 'display_plugin_admin_page')); 167 } 168 169 /** 170 * Plugin Settings Link on plugin page 171 * 172 * @since 1.0.0 173 * @return mixed The settings field 174 */ 175 public function add_settings_link( $links ) { 176 177 $mylinks = array( 178 '<a href="' . admin_url( "options-general.php?page=$this->name" ) . '">' . __( 'Settings', $this->name ) . '</a>', 179 ); 180 return array_merge( $links, $mylinks ); 181 } 182 183 /** 184 * Callback function for the admin settings page. 185 * 186 * @since 1.0.0 187 */ 188 public function display_plugin_admin_page(){ 189 190 // not sure why we need to flush the rules 191 flush_rewrite_rules(); 192 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/siteattention-admin-display.php'; 193 } 194 195 /** 196 * Settings - Validates saved options 197 * 198 * @since 1.0.0 199 * @param array $input array of submitted plugin options 200 * @return array array of validated plugin options 201 */ 202 public function process_settings( $input ) { 203 204 // Initialize the new array that will hold the sanitize values 205 $cleaned = array(); 206 207 if(isset($input)) { 208 // Loop through the input and sanitize each of the values 209 foreach ( $input as $key => $val ) { 210 211 // dont sanitize WP stuff 212 if( $key === 'post-type' ) { 213 $cleaned[ $key ] = $val; 214 } 215 216 else if( $key === 'custom_css' ) { 217 $cleaned[ $key ] = $val; 218 } 219 220 else if ( $key === 'custom_js' ) { 221 if ( !$val ) { 222 // Add default value 223 $default_js_path = plugin_dir_path( dirname( __FILE__ ) ) . 'admin/js/siteattention-default.js'; 224 225 if ( file_exists($default_js_path) ) { 226 $cleaned[ $key ] = file_get_contents( $default_js_path ); 227 } 228 } else { 229 $cleaned[ $key ] = $val; 230 } 231 } 232 233 else { 234 $cleaned[ $key ] = sanitize_text_field( $val ); 235 } 236 } 237 238 if ( !empty ( $cleaned['iid'] ) ) 239 { 240 $this->make_cors_post ( array ( 241 'func' => 'iname', 242 'iid' => $cleaned['iid'], 243 'name' => $cleaned['iname'], 244 )); 245 } 246 } 247 248 return $cleaned; 249 250 } 235 236 return $cleaned; 237 } 251 238 252 239 /** … … 257 244 * @return [type] [description] 258 245 */ 259 public function admin_sync_post( $post_ID, $post_after, $post_before ) { 260 261 $key = $this->option['key']; 262 $iid = $this->option['iid']; 263 264 if ( !$key ) { 265 return; 266 } 267 268 $published = ( $post_after->post_status === 'publish' ? 1 : 0 ); 269 $post_url = get_permalink( $post_ID ); 270 $language = get_locale(); 271 272 $this->make_cors_post ( array ( 273 'func' => 'publish', 246 public function admin_sync_post($post_ID,$post_after,$post_before) { 247 248 if (empty($this->option['key'])) return; 249 250 $published = ($post_after->post_status === 'publish' ? 1 : 0); 251 252 SiteAttention::callApi('customer/instance/page/publish',[ 274 253 'published' => $published, 254 'iid' => $this->option['iid'], 275 255 'pid' => $post_ID, 276 'url' => $post_url, 277 'lang' => $language, 278 'iid' => $iid, 279 )); 256 'url' => get_permalink($post_ID), 257 'lang' => get_locale(), 258 ]); 280 259 } 281 260 … … 284 263 * @return [type] [description] 285 264 */ 286 public function save_siteattention_info() { 287 288 global $wpdb; 289 290 if ( !empty($_POST['iid']) ) { 291 $this->option['iid'] = $_POST['iid']; 292 } 293 294 if ( !empty($_POST['iname']) ) { 295 $this->option['iname'] = $_POST['iname']; 296 } 297 298 if ( !empty($_POST['key']) ) { 299 $this->option['key'] = $_POST['key']; 300 } 301 302 if ( !empty($_POST['ilocked']) ) { 303 if ( filter_var( $_POST['ilocked'], FILTER_VALIDATE_BOOLEAN) ) { 304 $this->option['ilocked'] = 1; 305 } else { 306 $this->option['ilocked'] = 0; 307 } 308 } 265 public function save_settings() { 266 267 global $wp_query;//, $wpdb; 268 269 if 270 ( !isset($wp_query->query_vars['siteattention/settings']) 271 ) return; 272 273 $post = json_decode(file_get_contents('php://input'),true); 274 275 if (isset($post['iid'])) $this->option['iid'] = $post['iid']; 276 if (isset($post['iname'])) $this->option['iname'] = $post['iname']; 277 if (isset($post['key'])) $this->option['key'] = $post['key']; 278 if (isset($post['locked'])) $this->option['ilocked'] = $post['locked']; 309 279 310 280 update_option( $this->name, $this->option ); 311 281 312 wp_die(); 313 282 exit; 314 283 } 315 284 … … 407 376 return wp_scripts()->add_inline_script( $handle, $data, $position ); 408 377 } 409 410 /**411 * Making a CORS POST request to SA412 */413 public function make_cors_post ( $body )414 {415 $response = wp_remote_post( SiteAttention::URL . $this->option['key'], array416 (417 'method' => 'POST',418 'blocking' => false,419 'timeout' => 15,420 'sslverify' => false,421 'headers' => array422 (423 'Content-Type' => 'application/json',424 'X-SiteAttention' => $this->option['key'],425 'Referer' => get_site_url() . '/siteattention-wordpress',426 ),427 'redirection' => 0,428 'httpversion' => '1.1',429 'body' => json_encode ( $body ),430 ));431 432 //SiteAttention::write_log( $response );433 434 if ( is_wp_error ( $response ) )435 {436 //SiteAttention::write_log( $response );437 }438 439 else440 {441 //$body = json_decode ( $response [ 'body' ] , true );442 }443 }444 378 } -
siteattention/trunk/admin/dist/siteattention-admin.css
r1655166 r1736194 1 .CodeMirror{font-family:monospace;height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:-20px;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;font-variant-ligatures:contextual}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected,.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.siteattention-admin .postbox-main .hndle,.siteattention-admin .postbox-sidebar .hndle{cursor:auto}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}@media (max-width:1250px){.siteattention-on #postbox-container-1{width:100%!important;margin-right:0!important}.siteattention-on #postbox-container-1 #side-sortables{width:100%!important}.siteattention-on #poststuff{min-width:100%}.siteattention-on #poststuff #post-body.columns-2{margin-right:0}}.siteattention-on #slugdiv #post_name{width:100%}.siteattention-on #SAPL{position:fixed;right:0;bottom:0;z-index:99998}.siteattention-score .siteattention-score--logo{float:left;width:18px;height:18px;margin-right:5px;background-size:18px;background-image:url(../images/logo-icon.png)}.siteattention-on #SiteAttention,.siteattention-on #SiteAttention_minimized{z-index:99999}.siteattention-admin .postbox-main .code{display:none}.siteattention-admin .postbox-main .CodeMirror-scroll{background:#f9f9f9}.siteattention-admin .postbox-main input{width:100%}.siteattention-admin .postbox-main .siteattention-restore-js{margin-top:5px;display:block}@media screen and (max-width:1080px){.siteattention-admin .postbox-main .form-table td,.siteattention-admin .postbox-main .form-table th,.siteattention-admin .postbox-main .label-responsive{display:block;width:auto;vertical-align:middle}.siteattention-admin .postbox-main .form-table th{padding-top:0;padding-bottom:0;border-bottom:0}.siteattention-admin .postbox-main .form-table td{margin-bottom:0;padding-bottom:6px;padding-top:4px;padding-left:0}.siteattention-admin .postbox-main .siteattention-restore-js{margin-left:5px;vertical-align:baseline;display:inline}}.siteattention-admin .postbox-sidebar .postbox-logo{max-width:100%}.siteattention-admin .postbox-sidebar .postbox-loading{background:#f2f2f2;padding:7px;line-height:1.5}.siteattention-admin .postbox-sidebar .postbox-loading img{width:20px;vertical-align:middle}.siteattention-admin .postbox-sidebar .postbox-loading svg{fill:#444;vertical-align:middle} 1 2 2 /*# sourceMappingURL=siteattention-admin.css.map */ -
siteattention/trunk/admin/dist/siteattention-admin.js
r1716976 r1736194 1 "use strict"; var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}(function($){"use strict";var SiteAttentionWordPress=function(){function SiteAttentionWordPress(){_classCallCheck(this,SiteAttentionWordPress);this.domElements={wpContent:document.getElementById("wpcontent")}}_createClass(SiteAttentionWordPress,[{key:"getPid",value:function getPid(){return+SiteAttentionInfo.pid}},{key:"getIId",value:function getIId(){return SiteAttentionInfo.iid}},{key:"getCMS",value:function getCMS(){return SiteAttentionModule.Cms.WordPress}},{key:"getType",value:function getType(){return SiteAttentionInfo.post_type}},{key:"getLang",value:function getLang(){var lang=SiteAttentionInfo.language||navigator.language;if(lang){return lang.substring(0,2)}return null}},{key:"getUser",value:function getUser(){return SiteAttentionInfo.user_name}},{key:"getUrl",value:function getUrl(){return SiteAttentionInfo.url}},{key:"getPublished",value:function getPublished(){return SiteAttentionInfo.published==="1"}},{key:"getMap",value:function getMap(){var fields=[];if(SiteAttentionInfo.post_type==="post"||SiteAttentionInfo.post_type==="page"){fields=[{seo:"title",name:"Title",selector:"#title|0",type:"FieldInput"},{seo:"url",name:"Slug",selector:"#post_name|0",type:"FieldInput"},{seo:"metadescription",name:"Excerpt",selector:"#excerpt|0",type:"FieldInput"},{seo:"content",name:"Content",selector:"#content|0",type:"FieldTinyMCE4"},{seo:"headers",name:"Headers",selector:"#content|0",type:"FieldTinyMCE4"},{seo:"images",name:"Images",selector:"#content|0",type:"FieldTinyMCE4"},{seo:"videos",name:"Videos",selector:"#content|0",type:"FieldTinyMCE4"},{seo:"links",name:"Links",selector:"#content|0",type:"FieldTinyMCE4"}]}if(SiteAttentionInfo.post_type==="post"){fields.push({seo:"metakeywords",name:"Tags",selector:"#tax-input-post_tag|0",type:"FieldInput"})}return SiteAttentionModule.FieldFactory(fields)}},{key:"onShow",value:function onShow(){document.body.classList.add("siteattention-on")}},{key:"onHide",value:function onHide(){document.body.classList.remove("siteattention-on")}},{key:"onMinimise",value:function onMinimise(){this.domElements.wpContent.style.marginRight=0+"px"}},{key:"onMaximise",value:function onMaximise(){this.domElements.wpContent.style.marginRight=350+"px"}},{key:"permalinkEvent",value:function permalinkEvent(){$("#edit-slug-box").click(function(event){var el=document.getElementById("post_name");var e=document.createEvent("HTMLEvents");e.initEvent("keyup",false,true);el.dispatchEvent(e)})}},{key:"saveInformation",value:function saveInformation(status,key,instance){if(!status)return;var params={action:"save_siteattention_info",key:key,iid:instance.iid,iname:instance.name,ilocked:instance.locked};$.post(ajaxurl,params,function(data,textStatus,xhr){})}},{key:"saveInstance",value:function saveInstance(status,instance){if(!status)return;var params={action:"save_siteattention_info",iid:instance.iid,iname:instance.name,ilocked:instance.locked};$.post(ajaxurl,params,function(data,textStatus,xhr){})}},{key:"saveLicense",value:function saveLicense(status,key){if(!status)return;var params={action:"save_siteattention_info",key:key};$.post(ajaxurl,params,function(data,textStatus,xhr){})}},{key:"setScore",value:function setScore(status,data){if(!data)return;var readability=data.readability;var score=data.score;var html='\n <div id="siteattention-sidebarscore">\n <div id="siteattention-readability" class="misc-pub-section siteattention-score">\n <span class="siteattention-score--logo"></span>\n <span class="siteattention-score--title">Readability: <b>'+readability+'</b></span>\n </div>\n <div id="siteattention-score" class="misc-pub-section siteattention-score">\n <span class="siteattention-score--logo"></span>\n <span class="siteattention-score--title">SEO: <b>'+score+"%</b></span>\n </div>\n </div>\n ";$("#siteattention-sidebarscore").remove();$("#misc-publishing-actions").append(html)}},{key:"getContainer",value:function getContainer(){var wpcontent=document.getElementById("wpcontent"),container=document.createElement("div");wpcontent.style.marginRight="350px";container.id="SAPL";this.setContainerHeight(container,wpcontent);!function(setContainerHeight,container,wpcontent){window.addEventListener("resize",function(event){setContainerHeight(container,wpcontent)})}(this.setContainerHeight,container,wpcontent);document.body.appendChild(container);return container}},{key:"setContainerHeight",value:function setContainerHeight(container,wpcontent){var wpHtmlContainer=document.querySelector("html.wp-toolbar"),wpHtmlContainerStyle=window.getComputedStyle(wpHtmlContainer,null),wpHtmlContainerStylePaddingTop=wpHtmlContainerStyle.paddingTop,topPos=Number(wpHtmlContainerStylePaddingTop.slice(0,2)),height=window.innerHeight-topPos;container.style.height=height+"px"}},{key:"init",value:function init(){var _this=this;SiteAttention.play({container:this.getContainer(),minimised:false});SiteAttention.load({pid:this.getPid(),iid:this.getIId(),cms:this.getCMS(),type:this.getType(),lang:this.getLang(),user:this.getUser(),url:this.getUrl(),published:this.getPublished(),map:this.getMap()});this.onShow();this.permalinkEvent();SiteAttentionModule.hooks.add("after","register","Saving client information",function(s,k,i){return _this.saveInformation(s,k,i)});SiteAttentionModule.hooks.add("after","instance","Saving instance data",function(s,i){return _this.saveInstance(s,i)});SiteAttentionModule.hooks.add("after","license","Save existing license",function(s,k,i){return _this.saveInformation(s,k,i)});SiteAttentionModule.hooks.add("after","update","UI update",function(s,d){return _this.setScore(s,d)});SiteAttentionModule.hooks.add("after","minimise","Minimise",function(s){return _this.onMinimise(s)});SiteAttentionModule.hooks.add("after","maximise","Maximise",function(s){return _this.onMaximise(s)})}}]);return SiteAttentionWordPress}();$(window).load(function(){if(typeof SiteAttention!=="undefined"){(new SiteAttentionWordPress).init()}})})(jQuery);"use strict";(function($){"use strict";$(function(){if(typeof SA_SET==="boolean"&&SA_KEY){$.ajax({url:SA_URL+SA_KEY,type:"post",dataType:"json",data:{func:"info"},crossDomain:true,headers:{"X-SiteAttention":SA_KEY}}).done(function(data){var expires=new Date(data.expires).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});var out='\n <div class="customer-details-success">\n Company: '+data.company+" <br />\n Name: "+data.name+" <br />\n Email: "+data.email+" <br />\n License: "+data.license+" <br />\n Pages: "+data.active+" / "+data.limit+" <br />\n Expires: "+expires+" <br />\n </div>\n ";$("#siteattention-customer-details").html(out)}).fail(function(data){var out='\n <div class="customer-details-error">\n <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path d="M16.143 2l5.857 5.858v8.284l-5.857 5.858h-8.286l-5.857-5.858v-8.284l5.857-5.858h8.286zm.828-2h-9.942l-7.029 7.029v9.941l7.029 7.03h9.941l7.03-7.029v-9.942l-7.029-7.029zm-6.471 6h3l-1 8h-1l-1-8zm1.5 12.25c-.69 0-1.25-.56-1.25-1.25s.56-1.25 1.25-1.25 1.25.56 1.25 1.25-.56 1.25-1.25 1.25z"/></svg>\n An error occurred.\n </div>\n ';$("#siteattention-customer-details").html(out);console.log("error",data)})}})})(jQuery);1 "use strict";document.addEventListener("DOMContentLoaded",function(event){!function saInjectSettings(data){var id="SiteAttentionSettingsScript",url=data.apiUrl+"settings.js?",script=document.getElementById(id)?document.getElementById(id):document.createElement("script"),cb=function cb(event){document.readyState==="complete"||document.readyState==="interactive"?init():document.addEventListener("DOMContentLoaded",init)},init=function init(){new SiteAttentionSettings(data)};script.id?cb():null;script.type="text/javascript";script.src=url;script.id=id;script.addEventListener("load",cb,false);document.body.appendChild(script)}({apiUrl:SiteAttentionSettingsData.apiUrl,containerSelector:"#SiteAttentionSettings",cms:"WordPress",saVersion:SiteAttentionSettingsData.version,cmsUrl:SiteAttentionSettingsData.cmsUrl,cmsHeaders:{"Content-type":"application/json"},settings:{key:SiteAttentionSettingsData.key,iid:SiteAttentionSettingsData.iid,iname:SiteAttentionSettingsData.iname,locked:SiteAttentionSettingsData.locked}})}); 2 2 //# sourceMappingURL=siteattention-admin.js.map -
siteattention/trunk/admin/partials/siteattention-admin-display.php
r1655166 r1736194 14 14 ?> 15 15 16 <script> 17 const SA_SET = true; 18 const SA_URL = '<?= SiteAttention::URL ?>'; 19 const SA_KEY = '<?= $this->option['key'] ?>'; 20 </script> 21 22 <div class="wrap siteattention-admin"> 23 24 <h2><?= esc_html( get_admin_page_title() ); ?></h2> 25 26 <div id="poststuff"> 27 28 <div id="post-body" class="metabox-holder columns-2 postbox-main"> 29 30 <!-- Settings --> 31 <div id="postbox-container-2" class="postbox-container"> 32 33 <form method="post" action="options.php"> 34 <div id="normal-sortables" class="meta-box-sortables ui-sortable"> 35 <div id="itsec_get_started" class="postbox "> 36 <h3 class="hndle"><span><?php _e( 'General Settings', $this->name ); ?></span></h3> 37 <div class="inside"> 38 <?php 39 settings_fields( $this->name ); 40 41 do_settings_sections( $this->name ); 42 43 submit_button( __( 'Save Settings', $this->name ) ); 44 ?> 45 <div class="clear"></div> 46 </div> 47 </div> 48 </div> 49 </form> 50 51 </div> 52 <!-- Settings --> 53 54 <!-- Customer details--> 55 <div id="postbox-container-1" class="postbox-container postbox-sidebar"> 56 <div id="priority_side-sortables" class="meta-box-sortables ui-sortable"> 57 <div id="itsec_security_updates" class="postbox"> 58 <h3 class="hndle"> 59 <?= '<img class="postbox-logo" src="' . plugins_url( '/images/logo.png', dirname(__FILE__) ) . '" > ';?> 60 </h3> 61 <div class="inside"> 62 <p> 63 <label><?php _e( 'Web:' , $this->name); ?></label> 64 65 <a href="https://siteattention.com" title="<?php _e( 'Visit our homepage', $this->name ); ?>" target="_blank">https://siteattention.com</a> 66 <br /> 67 68 <label><?php _e( 'Email:', $this->name ); ?></label> 69 <a href="mailto:[email protected]" title="<?php _e( 'Send us an email', $this->name ); ?>" target="_blank">[email protected]</a> 70 </p> 71 72 <div id="siteattention-customer-details" class="postbox-loading"> 73 <div class="customer-details-loading"> 74 <?php if ($this->option['key']): ?> 75 <?= '<img src="' . plugins_url( '/images/loading.gif', dirname(__FILE__) ) . '" > ';?> 76 77 <?php _e( 'Fetching information.', $this->name ); ?> 78 <?php else: ?> 79 <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path d="M16.143 2l5.857 5.858v8.284l-5.857 5.858h-8.286l-5.857-5.858v-8.284l5.857-5.858h8.286zm.828-2h-9.942l-7.029 7.029v9.941l7.029 7.03h9.941l7.03-7.029v-9.942l-7.029-7.029zm-6.471 6h3l-1 8h-1l-1-8zm1.5 12.25c-.69 0-1.25-.56-1.25-1.25s.56-1.25 1.25-1.25 1.25.56 1.25 1.25-.56 1.25-1.25 1.25z"/></svg> 80 81 <?php _e( 'No license key.', $this->name ); ?> 82 <?php endif; ?> 83 </div> 84 </div> 85 86 </div> 87 </div> 88 </div> 89 </div> 90 <!-- Customer details--> 91 92 </div> 93 </div> 94 95 </div> 16 <div id="SiteAttentionSettings"></div> -
siteattention/trunk/includes/class-siteattention.php
r1686809 r1736194 30 30 class SiteAttention { 31 31 32 /** 33 * The unique identifier of this plugin. 34 * 35 * @since 1.0.0 36 * @access public 37 * @var string $name The string used to uniquely identify this plugin. 38 */ 39 const NAME = SITEATTENTION_NAME; 40 41 /** 42 * The current version of the plugin. 43 * 44 * @since 1.0.0 45 * @access public 46 * @var string $version The current version of the plugin. 47 */ 48 const VERSION = SITEATTENTION_VERSION; 49 50 /** 51 * The URL of the SiteAttention API 52 * 53 * @since 1.0.0 54 * @access public 55 * @var string $version The current version of the plugin. 56 */ 32 private $option; 33 protected $loader; 34 35 const NAME = SITEATTENTION_NAME; 36 const VERSION = SITEATTENTION_VERSION; 57 37 const URL = SITEATTENTION_URL; 58 38 59 /** 60 * The loader that's responsible for maintaining and registering all hooks that power 61 * the plugin. 62 * 63 * @since 1.0.0 64 * @access protected 65 * @var SiteAttention_Loader $loader Maintains and registers all hooks for the plugin. 66 */ 67 protected $loader; 68 69 /** 70 * The WordPress options specific to SiteAttention 71 * 72 * @since 1.0.0 73 * @access private 74 * @var string $version The current version of this plugin. 75 */ 76 private $option; 77 78 /** 79 * Initializes the WordPress option for SiteAttention 80 * 81 * @since 1.0.0 82 * @access public 83 * @var string $version The current version of this plugin. 84 */ 85 public static function initOption (){ 39 public function __construct() { 40 41 $this->load_dependencies(); 42 $this->set_locale(); 43 $this->define_admin_hooks(); 44 $this->define_public_hooks(); 45 46 $this->option = get_option(self::NAME); 47 } 48 49 50 public static function resetOptions($uninstall=false){ 86 51 $options = get_option ( self::NAME ); 87 52 self::saveOptions([ 53 'key' => $uninstall ? '' : isset ( $options['key']) ? $options['key'] : '', 54 'iid' => isset ( $options['iid']) ? $options['iid'] : '', 55 'iname' => isset ( $options['iname']) ? $options['iname'] : '', 56 'ilocked' => isset ( $options['ilocked']) ? $options['ilocked'] : false, 57 'guid' => isset ( $options['guid']) ? $options['guid'] : '', 58 'installed' => $uninstall ? false : isset($options['installed']) ? $options['installed'] : false, 59 ]); 60 } 61 62 public static function saveOptions($data){ 88 63 delete_option ( self::NAME ); 89 90 // $defaultJsSrc = ''; 91 // $defaultJsPath = plugin_dir_path ( dirname ( __FILE__ ) ) . 'admin/js/siteattention-default.js'; 92 // 93 // if ( file_exists ( $defaultJsPath ) ) { 94 // 95 // $defaultJsSrc = file_get_contents ( $defaultJsPath ); 96 // } 97 98 add_option ( self::NAME, array 99 ( 100 'key' => isset ( $options [ 'key' ] ) ? $options [ 'key' ] : '', 101 'iid' => isset ( $options [ 'iid' ] ) ? $options [ 'iid' ] : '', 102 'iname' => isset ( $options [ 'iname' ] ) ? $options [ 'iname' ] : '', 103 'ilocked' => isset ( $options [ 'ilocked' ] ) ? $options [ 'ilocked' ] : '', 104 //'css' => isset ( $options [ 'css' ] ) || $defaultCssSrc, 105 //'js' => isset ( $options [ 'js' ] ) || $defaultJsSrc, 106 ) ); 107 } 108 109 /** 110 * Resets the WordPress option for SiteAttention 111 * 112 * @since 1.0.0 113 * @access public 114 * @var string $version The current version of this plugin. 115 */ 116 public static function resetOption (){ 117 $options = get_option ( self::NAME ); 118 119 delete_option ( self::NAME ); 120 121 add_option ( self::NAME, array 122 ( 123 'iid' => isset ( $options [ 'iid' ] ) ? $options [ 'iid' ] : '', 124 'iname' => isset ( $options [ 'iname' ] ) ? $options [ 'iname' ] : '', 125 'ilocked' => isset ( $options [ 'ilocked' ] ) ? $options [ 'ilocked' ] : '', 126 ) ); 127 } 128 129 /** 130 * Logging to the error log 131 * 132 * @since 1.0.0 133 * @return string Initializes/ resets plugin's options 134 */ 64 add_option ( self::NAME, [ 65 'key' => isset ( $data['key']) ? $data['key'] : '', 66 'iid' => isset ( $data['iid']) ? $data['iid'] : '', 67 'iname' => isset ( $data['iname']) ? $data['iname'] : '', 68 'ilocked' => isset ( $data['ilocked']) ? $data['ilocked'] : false, 69 'guid' => isset ( $data['guid']) ? $data['guid'] : '', 70 'installed' => isset ( $data['installed']) ? $data['installed'] : false, 71 ]); 72 } 73 74 public static function sendPluginEvent($type){ 75 global $wp_version; 76 $options = get_option(self::NAME); 77 78 return self::callApi('record',[ 79 'meta' => [ 80 'timestamp' => date('Y-m-d H:i:s'), 81 'event' => 'plugin', 82 'type' => $type, 83 'key' => $options['key'], 84 'instance' => $options['iid'], 85 'guid' => $options['guid'], 86 'browser' => 'WordPress/PHP' . phpversion(), 87 'cms' => 'WordPress', 88 'domain' => get_site_url() 89 ], 90 'data' => [ 91 'cmsVersion' => $wp_version, 92 'saVersion' => self::VERSION 93 ] 94 ]); 95 } 96 97 public static function callApi($route,$body){ 98 $options = get_option(self::NAME); 99 $response = wp_remote_post( self::URL . $route, [ 100 'headers' => [ 101 'Content-Type' => 'application/json', 102 'X-SiteAttention' => $options['key'], 103 'Referer' => get_site_url() . '/siteattention-wordpress', 104 ], 105 'method' => 'POST', 106 'body' => json_encode($body), 107 'timeout' => 15, 108 // 'blocking' => false, 109 // 'sslverify' => false, 110 // 'redirection' => 0, 111 // 'httpversion' => '1.1', 112 ]); 113 114 if (is_wp_error($response)) 115 { 116 return false; 117 } 118 119 else 120 { 121 return json_decode($response['body'],true); 122 } 123 } 124 135 125 public static function write_log( $log ){ 136 126 $content = "SiteAttention:\n"; … … 149 139 } 150 140 151 /** 152 * Define the core functionality of the plugin. 153 * 154 * Set the plugin name and the plugin version that can be used throughout the plugin. 155 * Load the dependencies, define the locale, and set the hooks for the admin area and 156 * the public-facing side of the site. 157 * 158 * @since 1.0.0 159 */ 160 public function __construct() { 161 162 $this->load_dependencies(); 163 $this->set_locale(); 164 $this->define_admin_hooks(); 165 $this->define_public_hooks(); 166 167 $this->option = get_option ( self::NAME ); 168 } 169 170 /** 171 * Run the loader to execute all of the hooks with WordPress. 172 * 173 * @since 1.0.0 174 */ 175 public function run() { 176 $this->loader->run(); 177 } 178 179 /** 180 * The reference to the class that orchestrates the hooks with the plugin. 181 * 182 * @since 1.0.0 183 * @return SiteAttention_Loader Orchestrates the hooks of the plugin. 184 */ 185 public function get_loader() { 186 return $this->loader; 187 } 188 189 /** 190 * Load the required dependencies for this plugin. 191 * 192 * Include the following files that make up the plugin: 193 * 194 * - SiteAttention_Loader. Orchestrates the hooks of the plugin. 195 * - SiteAttention_i18n. Defines internationalization functionality. 196 * - SiteAttention_Admin. Defines all hooks for the admin area. 197 * - SiteAttention_Public. Defines all hooks for the public side of the site. 198 * 199 * Create an instance of the loader which will be used to register the hooks 200 * with WordPress. 201 * 202 * @since 1.0.0 203 * @access private 204 */ 205 private function load_dependencies() { 206 207 /** 208 * The class responsible for orchestrating the actions and filters of the 209 * core plugin. 210 */ 211 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-siteattention-loader.php'; 212 213 /** 214 * The class responsible for defining internationalization functionality 215 * of the plugin. 216 */ 217 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-siteattention-i18n.php'; 218 219 /** 220 * The class responsible for defining all actions that occur in the admin area. 221 */ 222 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-siteattention-admin.php'; 223 224 /** 225 * The class responsible for defining all Settings. 226 */ 227 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/settings/class-siteattention-settings.php'; 228 229 /** 230 * The class responsible for defining all actions that occur in the public-facing 231 * side of the site. 232 */ 233 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-siteattention-public.php'; 234 235 $this->loader = new SiteAttention_Loader(); 236 237 } 238 239 /** 240 * Define the locale for this plugin for internationalization. 241 * 242 * Uses the SiteAttention_i18n class in order to set the domain and to register the hook 243 * with WordPress. 244 * 245 * @since 1.0.0 246 * @access private 247 */ 248 private function set_locale() { 249 250 $plugin_i18n = new SiteAttention_i18n( self::NAME ); 251 252 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 253 } 254 255 /** 256 * Register all of the hooks related to the admin area functionality 257 * of the plugin. 258 * 259 * @since 1.0.0 260 * @access private 261 */ 262 private function define_admin_hooks() { 263 264 $plugin_admin = new SiteAttention_Admin( self::NAME , self::VERSION ); 265 $settings_init_general = new SiteAttention_Settings( self::NAME , self::VERSION); 141 142 public function run() { 143 $this->loader->run(); 144 } 145 146 public function get_loader() { 147 return $this->loader; 148 } 149 150 private function load_dependencies() { 151 152 /** 153 * The class responsible for orchestrating the actions and filters of the 154 * core plugin. 155 */ 156 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-siteattention-loader.php'; 157 158 /** 159 * The class responsible for defining internationalization functionality 160 * of the plugin. 161 */ 162 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-siteattention-i18n.php'; 163 164 /** 165 * The class responsible for defining all actions that occur in the admin area. 166 */ 167 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-siteattention-admin.php'; 168 169 /** 170 * The class responsible for defining all Settings. 171 */ 172 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/settings/class-siteattention-settings.php'; 173 174 /** 175 * The class responsible for defining all actions that occur in the public-facing 176 * side of the site. 177 */ 178 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-siteattention-public.php'; 179 180 $this->loader = new SiteAttention_Loader(); 181 } 182 183 private function set_locale() { 184 185 $plugin_i18n = new SiteAttention_i18n( self::NAME ); 186 187 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 188 } 189 190 private function define_admin_hooks() { 191 192 $plugin_admin = new SiteAttention_Admin( self::NAME , self::VERSION ); 266 193 267 194 // Add the SiteAttention styles and scripts 268 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );269 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );195 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); 196 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); 270 197 271 198 // Setup plugin settings link 272 $this->loader->add_action( 'admin_menu', $plugin_admin, 'siteattention_admin_menu' ); 273 $this->loader->add_action( 'admin_init', $settings_init_general, 'settings_api_init' ); 274 $this->loader->add_filter( 'plugin_action_links_siteattention/siteattention.php', $plugin_admin, 'add_settings_link' , 10 , 1 ); 199 $this->loader->add_action( 'admin_menu', $plugin_admin, 'siteattention_admin_menu' ); 200 $this->loader->add_filter( 'plugin_action_links_siteattention/siteattention.php', $plugin_admin, 'add_settings_link' , 10 , 1 ); 275 201 276 202 // Syncronization hook with SiteAttention backend 277 203 $this->loader->add_action( 'post_updated', $plugin_admin, 'admin_sync_post', 10, 3 ); 278 204 279 // Save SiteAttention informations 280 $this->loader->add_action( 'wp_ajax_save_siteattention_info', $plugin_admin, 'save_siteattention_info' ); 205 // SiteAttention settings endpoint 206 $this->loader->add_action( 'init', $plugin_admin, 'add_settings_route' ); 207 $this->loader->add_action( 'template_redirect', $plugin_admin, 'save_settings' ); 281 208 282 209 // Add Excerpt section to pages edit page … … 285 212 // Show meta boxes by default 286 213 $this->loader->add_filter( 'hidden_meta_boxes', $plugin_admin, 'show_meta_boxes', 10, 2); 287 } 288 289 /** 290 * Register all of the hooks related to the public-facing functionality 291 * of the plugin. 292 * 293 * @since 1.0.0 294 * @access private 295 */ 296 private function define_public_hooks() { 297 298 $plugin_public = new SiteAttention_Public( self::NAME , self::VERSION ); 214 } 215 216 private function define_public_hooks() { 217 218 $plugin_public = new SiteAttention_Public( self::NAME , self::VERSION ); 299 219 300 220 // Add the SiteAttention styles and scripts 301 221 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); 302 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );222 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 303 223 304 224 // Add default metakeywords and metadescription 305 225 $this->loader->add_action( 'wp_head', $plugin_public, 'add_meta_tags' ); 306 }226 } 307 227 } -
siteattention/trunk/siteattention.php
r1695813 r1736194 16 16 * Plugin Name: SiteAttention 17 17 * Description: Simple and intuitive SEO tool to help improve seach ranking. 18 * Version: 1.0. 418 * Version: 1.0.5 19 19 * Author: siteattention 20 20 * Author URI: https://siteattention.com … … 25 25 */ 26 26 27 27 28 // If this file is called directly, abort. 28 if ( ! defined( 'WPINC' ) ) { 29 die; 30 } 31 32 /** 33 * The code that runs during plugin activation. 34 * This action is documented in includes/class-siteattention-activator.php 35 */ 36 function activate_siteattention() { 37 require_once plugin_dir_path( __FILE__ ) . 'includes/class-siteattention-activator.php'; 38 SiteAttention_Activator::activate(); 39 } 40 41 /** 42 * The code that runs during plugin deactivation. 43 * This action is documented in includes/class-siteattention-deactivator.php 44 */ 45 function deactivate_siteattention() { 46 require_once plugin_dir_path( __FILE__ ) . 'includes/class-siteattention-deactivator.php'; 47 SiteAttention_Deactivator::deactivate(); 48 } 49 50 register_activation_hook( __FILE__, 'activate_siteattention' ); 51 register_deactivation_hook( __FILE__, 'deactivate_siteattention' ); 29 if (!defined('WPINC')) die; 52 30 53 31 … … 57 35 */ 58 36 require_once plugin_dir_path( __FILE__ ) . 'includes/class-siteattention.php'; 37 38 39 function activate_siteattention() { 40 SiteAttention::resetOptions(); 41 $options = get_option(SiteAttention::NAME); 42 43 if (empty($options['install'])) 44 { 45 $response = SiteAttention::sendPluginEvent('install'); 46 47 if 48 ( 49 empty($options['guid']) && 50 !empty($response['data']['guid']) 51 ) 52 { 53 $options['guid'] = $response['data']['guid']; 54 } 55 56 $options['installed'] = true; 57 SiteAttention::saveOptions($options); 58 } 59 60 SiteAttention::sendPluginEvent('enable'); 61 } 62 63 64 function deactivate_siteattention() { 65 SiteAttention::sendPluginEvent('disable'); 66 flush_rewrite_rules(); 67 } 68 69 70 function update_siteattention() { 71 SiteAttention::sendPluginEvent('update'); 72 } 73 74 75 function uninstall_siteattention() { 76 SiteAttention::sendPluginEvent('uninstall'); 77 SiteAttention::resetOptions(true); 78 } 79 80 81 function action_upgrader_process_complete($upgrader,$options) { 82 $siteattention = plugin_basename( __FILE__ ); 83 84 if 85 ( 86 $options['type'] == 'plugin' && 87 $options['action'] == 'update' && 88 isset($options['plugins']) && 89 in_array($siteattention,$options['plugins']) 90 ) 91 { 92 update_siteattention(); 93 } 94 } 95 96 97 // register the hooks for activation, deactivation, install, upgrade, uninstall 98 add_action( 'upgrader_process_complete', 'action_upgrader_process_complete', 20, 2 ); 99 register_activation_hook( __FILE__, 'activate_siteattention' ); 100 register_deactivation_hook( __FILE__, 'deactivate_siteattention' ); 101 register_uninstall_hook(__FILE__, 'uninstall_siteattention'); 59 102 60 103 /** … … 68 111 */ 69 112 70 define ( 'SITEATTENTION_VERSION' , '1.0.4' ); 113 114 define ( 'SITEATTENTION_VERSION' , '1.0.5' ); 71 115 define ( 'SITEATTENTION_NAME' , 'SiteAttention' ); 72 116 define ( 'SITEATTENTION_URL' , 'https://api.siteattention.com/' ); 117 //define ( 'SITEATTENTION_URL' , 'https://dev.siteattention.com/' ); 73 118 //define ( 'SITEATTENTION_URL' , 'http://api.local/' ); 74 75 119 76 120 $SiteAttention = new SiteAttention();
Note: See TracChangeset
for help on using the changeset viewer.