Plugin Directory

Changeset 1693783


Ignore:
Timestamp:
07/10/2017 01:49:13 PM (9 years ago)
Author:
adtechmedia
Message:

Fix for WP 4.5 and plugin All in One Schema

Location:
adtechmedia/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • adtechmedia/trunk/adtechmedia-plugin.php

    r1684514 r1693783  
    194194                    $this->add_plugin_option( 'api-token-sent', true );
    195195                }
    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_token
    203                     );
    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                 }
    223196            }
    224197
     
    284257            )
    285258        );
     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        }
    286296    }
    287297
  • adtechmedia/trunk/adtechmedia-request.php

    r1687719 r1693783  
    2929            'ContentId' => $content_id,
    3030            'PropertyId' => $property_id,
    31             'Content' => addslashes( preg_replace( '/\n/', '', $content ) ),
     31            'Content' => $content,
    3232        ];
    3333        $response = self::make(
  • adtechmedia/trunk/css/main.css

    r1592142 r1693783  
    17341734    left: 100%;
    17351735}
     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  
    3434    type: type,
    3535    text: text,
    36     timeout: 3000,
     36    timeout: 3000
    3737  });
    3838}, 3500);
     
    5050      action: 'send_api_token',
    5151      nonce: send_api_token.nonce,
    52       return_link_tpl: window.location.toString(),
     52      return_link_tpl: window.location.toString()
    5353    },
    5454    success: function(response) {
     
    320320  const tplManager = atmTplManager(isLocalhost ? 'dev' : 'prod');
    321321  const runtime = tplManager.rendition().render('#template-editor');
     322  let firstSaveTemplates = false;
    322323
    323324  runtime.showSettings = true;
     
    327328  tplManager
    328329    .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;
    336339    })
    337340    .then(function() {
     
    352355                action: 'save_template',
    353356                nonce: save_template.nonce,
    354                 appearanceSettings: JSON.stringify(tplManager.generalSettings),
     357                appearanceSettings: JSON.stringify(tplManager.generalSettings)
    355358              },
    356359              success: function(response) {
     
    373376        syncTemplates(true);
    374377      });
    375        
    376       if (forceSaveTemplates) {
     378
     379      if (forceSaveTemplates || firstSaveTemplates) {
    377380        syncTemplates();
    378381      }
    379382    });
    380383});
     384
     385jQuery().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  
    113113    .atm-targeted-container {
    114114        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;
    115132    }
    116133</style>
Note: See TracChangeset for help on using the changeset viewer.