Changeset 1693783
- Timestamp:
- 07/10/2017 01:49:13 PM (9 years ago)
- Location:
- adtechmedia/trunk
- Files:
-
- 1 added
- 5 edited
-
adtechmedia-plugin.php (modified) (2 diffs)
-
adtechmedia-request.php (modified) (1 diff)
-
css/main.css (modified) (1 diff)
-
images/loading.svg (added)
-
js/main.js (modified) (6 diffs)
-
views/admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
adtechmedia/trunk/adtechmedia-plugin.php
r1684514 r1693783 194 194 $this->add_plugin_option( 'api-token-sent', true ); 195 195 } 196 197 if ( isset( $_GET['atm-token'] ) && ! empty( $_GET['atm-token'] ) ) {198 $atm_token = sanitize_text_field( wp_unslash( $_GET['atm-token'] ) );199 200 $key_response = Adtechmedia_Request::api_token2key(201 $this->get_plugin_option( 'support_email' ),202 $atm_token203 );204 $key = $key_response['apiKey'];205 206 if ( ! empty( $key ) ) {207 $this->delete_plugin_option( 'api-token-sent' );208 $this->add_plugin_option( 'key', $key );209 $this->add_plugin_option( 'client-id', $key_response['clientId'] );210 $this->add_plugin_option( 'admin-redirect', true );211 $this->add_plugin_option( 'force-save-templates', true );212 $this->update_prop();213 $this->update_appearance();214 215 add_action( 'admin_init',216 array(217 &$this,218 'admin_redirect',219 )220 );221 }222 }223 196 } 224 197 … … 284 257 ) 285 258 ); 259 add_action( 'wp_ajax_key_from_token', 260 array( 261 &$this, 262 'key_from_token', 263 ) 264 ); 265 } 266 267 /** 268 * Get key from token with API 269 */ 270 public function key_from_token() { 271 // @codingStandardsIgnoreStart 272 if ( isset( $_POST['atm_token'] ) && ! empty( $_POST['atm_token'] ) ) { 273 $atm_token = sanitize_text_field( wp_unslash( $_POST['atm_token'] ) ); 274 // @codingStandardsIgnoreEnd 275 276 $key_response = Adtechmedia_Request::api_token2key( 277 $this->get_plugin_option( 'support_email' ), 278 $atm_token 279 ); 280 $key = $key_response['apiKey']; 281 282 if ( ! empty( $key ) ) { 283 $this->delete_plugin_option( 'api-token-sent' ); 284 $this->add_plugin_option( 'key', $key ); 285 $this->add_plugin_option( 'client-id', $key_response['clientId'] ); 286 $this->add_plugin_option( 'admin-redirect', true ); 287 $this->add_plugin_option( 'force-save-templates', true ); 288 $this->update_prop(); 289 $this->update_appearance(); 290 // @codingStandardsIgnoreStart 291 echo $key; 292 // @codingStandardsIgnoreEnd 293 } 294 wp_die(); 295 } 286 296 } 287 297 -
adtechmedia/trunk/adtechmedia-request.php
r1687719 r1693783 29 29 'ContentId' => $content_id, 30 30 'PropertyId' => $property_id, 31 'Content' => addslashes( preg_replace( '/\n/', '', $content ) ),31 'Content' => $content, 32 32 ]; 33 33 $response = self::make( -
adtechmedia/trunk/css/main.css
r1592142 r1693783 1734 1734 left: 100%; 1735 1735 } 1736 1737 .content .preloader{ 1738 background-image: url("../images/loading.svg"); 1739 background-repeat: no-repeat; 1740 background-position: center; 1741 background-color: transparent; 1742 box-shadow: none; 1743 } -
adtechmedia/trunk/js/main.js
r1684777 r1693783 34 34 type: type, 35 35 text: text, 36 timeout: 3000 ,36 timeout: 3000 37 37 }); 38 38 }, 3500); … … 50 50 action: 'send_api_token', 51 51 nonce: send_api_token.nonce, 52 return_link_tpl: window.location.toString() ,52 return_link_tpl: window.location.toString() 53 53 }, 54 54 success: function(response) { … … 320 320 const tplManager = atmTplManager(isLocalhost ? 'dev' : 'prod'); 321 321 const runtime = tplManager.rendition().render('#template-editor'); 322 let firstSaveTemplates = false; 322 323 323 324 runtime.showSettings = true; … … 327 328 tplManager 328 329 .authorizeAndSetup(apiKey, propertyId) 329 .then(function(exists) { 330 return exists 331 ? tplManager.fetch() 332 : tplManager.createDefaults( 333 propertyId, themeId, platformId, 334 themeVersion, platformVersion 335 ); 330 .then(function(exists) { 331 let result; 332 if (exists) { 333 result = tplManager.fetch(); 334 } else { 335 result = tplManager.createDefaults(ropertyId, themeId, platformId, themeVersion, platformVersion); 336 firstSaveTemplates = true; 337 } 338 return result; 336 339 }) 337 340 .then(function() { … … 352 355 action: 'save_template', 353 356 nonce: save_template.nonce, 354 appearanceSettings: JSON.stringify(tplManager.generalSettings) ,357 appearanceSettings: JSON.stringify(tplManager.generalSettings) 355 358 }, 356 359 success: function(response) { … … 373 376 syncTemplates(true); 374 377 }); 375 376 if (forceSaveTemplates ) {378 379 if (forceSaveTemplates || firstSaveTemplates) { 377 380 syncTemplates(); 378 381 } 379 382 }); 380 383 }); 384 385 jQuery().ready(function() { 386 var url = window.location.href; 387 var apiToken = (/atm-token/gi.test(url)) 388 ? url.match(/atm-token=([^&]+)/)[1] 389 : ''; 390 391 if (apiToken) { 392 jQuery('.atm-missing-key-msg').addClass('preloader'); 393 jQuery('.atm-missing-key-msg *').css('opacity', 0); 394 jQuery.ajax({ 395 url: ajaxurl, 396 type: 'post', 397 data: { 398 action: 'key_from_token', 399 atm_token: apiToken 400 }, 401 success: function(response) { 402 if (response.length > 0) { 403 window.location = url.replace(/\&atm-token=([^&]+)/, ''); 404 } 405 }, 406 error: function(response) { 407 notify('error', 'Error requesting AdTechMedia api authorization token. Please try again later...'); 408 } 409 }); 410 } 411 }); -
adtechmedia/trunk/views/admin.php
r1684514 r1693783 113 113 .atm-targeted-container { 114 114 z-index: 0 !important; 115 } 116 117 /*fix for wp 4.5 and plugin All in One Schema*/ 118 .vue-tabs li.tab { 119 border:0; 120 } 121 .vue-tabs li.tab.active { 122 padding-top: 0; 123 top:0; 124 } 125 .vue-tabs li.tab.active a:focus { 126 -webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); 127 box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); 128 } 129 .editor-container .tabs-container .tab-container { 130 width: initial; 131 float: initial; 115 132 } 116 133 </style>
Note: See TracChangeset
for help on using the changeset viewer.