Plugin Directory

Changeset 1674966


Ignore:
Timestamp:
06/09/2017 06:31:34 PM (9 years ago)
Author:
ErinMorelli
Message:

Releasing plugin v3.1.0

Location:
em-beer-manager
Files:
74 added
3 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • em-beer-manager/trunk/README.txt

    r1647727 r1674966  
    22Contributors: ErinMorelli
    33Donate link: http://www.erinmorelli.com/projects/em-beer-manager/
    4 Tags: beer, beers, brewery, untappd
     4Tags: beer, beers, brewery, untappd, untappd for business
    55Requires at least: 3.0.1
    6 Tested up to: 4.7.2
    7 Stable tag: 3.0.5
     6Tested up to: 4.8.0
     7Stable tag: 3.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Manage your beers with WordPress. Integrates simply with Untappd beer check-ins. Great for everyone from home brewers to professional breweries!
     11Manage and display your beers with WordPress. Integrates simply with Untappd and Untappd for Business. Great for everyone from home brewers to professional breweries!
    1212
    1313
     
    1818* A custom beer "style" taxonomy for classifying your beers pre-populated with styles from Untappd
    1919* A customizable "group" taxonomy for categorizing and grouping your beers
     20* "Menu" taxonomy for creating beer menus
    2021* Shortcodes and template tags for displaying all or a select number of beers
    2122* Custom meta boxes to store detailed information about each beer, including ABV, IBU, and ingredients
     
    2425* A "Recent Check-Ins" widget for displaying recent beer check-ins for your brewery on Untappd
    2526* Custom page display for beers and styles
    26 * [Experimental] Import your brewery's beers directly from Untappd
     27* [Beta] Import your brewery's beers directly from Untappd
     28* [Beta] Import your beers and menus from Untappd for Business
    2729
    2830= Usage =
     
    157159== Frequently Asked Questions ==
    158160
     161= Can I use content filters with EM Beer Manager? =
     162
     163Yes! New in v3.1.0, you can apply content filters to different parts of EM Beer Manager's output:
     164
     165* `embm_beer_filter_beer` = The full beer post content
     166* `embm_beer_filter_untappd` = The Untappd check-in button
     167* `embm_beer_filter_profile` = The beer profile content
     168* `embm_beer_filter_extras` = The beer extras content
     169* `embm_beer_filter_rating` = The full beer rating content
     170* `embm_beer_filter_rating_stars` = Just the stars of the rating content
     171* `embm_beer_filter_rating_styles` = CSS styles for the rating stars
     172* `embm_beer_filter_reviews` = The beer reviews content
     173
     174
     175= Why is an Untappd account required in addition to an UTFB account? =
     176
     177Untappd for Business (UTFB) account credentials do not work with Untappd's API. In order to link Untappd data to beers imported from UTFB, Untappd API access is also needed.
     178
     179An Untappd brewery account is not required to work with UTFB. A standard user account will work.
     180
     181
     182= Where do I find my Untappd for Business API key? =
     183
     184You can find your API key under the ["API Access Tokens"](https://business.untappd.com/api_tokens) section of your account.
     185
     186
    159187= Why am I seeing a "rate-limit" error? =
    160188
     
    236264
    237265Try refreshing your permalinks by going to "Settings" -> "Permalinks" and clicking the "Save Settings" button. If you are running EM Beer Manager 1.7.1 or earlier, it may be due to your site's theme overriding the EM Beer Manager templates. We recommend updating to version 1.8.0 or higher, but you can  also edit the templates in the plugin file to suit your needs. They're located in wp-content -> plugins -> em-beer-manager -> templates.
    238 
    239 
    240266
    241267
     
    253279== Changelog ==
    254280
     281= 3.1.0 =
     282* [NEW] Connect to and import beers/menus from your Untappd for Business account
     283* [NEW] Sync your imported beers with changes from Untappd
     284* [NEW] Beer images now link to their respective beer
     285* [FIXED] Bug with how beer styles were displaying in titles
     286
    255287= 3.0.5 =
    256288* [FIXED] Broken brewery account authentication for Labs
     
    389421
    390422
    391 
    392423== Upgrade Notice ==
     424
     425= 3.1.0 =
     426Adds support for Untappd for Business accounts
    393427
    394428= 3.0.5 =
     
    458492* Norwegian Bokmål (nb_NO) - *thanks to __[Lars Kvisle](http://www.lars.kvisle.no)__*
    459493* Brazilian Portuguese (pt_BR) - *thanks to __Lucas Alexandre__*
    460 
    461 
    462 == Planned Features ==
    463 
    464 * Post/Page “Add Beer” page/post editor button to auto-generate shortcode input
    465 * Customization for “Beer Profile” input fields (e.g. allow users to remove “Additions/Spices” or add “OG”)
    466 * Allow users to select additional fields to show in the beer list widget (e.g. "ABV")
  • em-beer-manager/trunk/assets/beer-styles.txt

    r1584363 r1674966  
    8484Lambic - Kriek
    8585Lambic - Other
    86 Maibock/Helles Bock
     86Maibock / Heller (Helles) Bock
    8787Malt Beer
    8888Malt Liquor
  • em-beer-manager/trunk/assets/css/admin.css

    r1584363 r1674966  
    11/**
    2  * Copyright (c) 2013-2016, Erin Morelli.
     2 * Copyright (c) 2013-2017, Erin Morelli.
    33 *
    44 * This program is free software; you can redistribute it and/or
     
    153153    width: 50px;
    154154}
    155 .embm-settings--page .embm-settings--status .embm-untappd--user-link {
     155.embm-settings--page .embm-settings--status .embm-untappd--user-link,
     156.embm-settings--page .embm-settings--status .embm-utfb--account-link {
    156157    text-decoration: none;
    157158}
    158 .embm-settings--page .embm-settings--status .embm-untappd--user-link .dashicons::before {
     159.embm-settings--page .embm-settings--status .embm-untappd--user-link .dashicons::before,
     160.embm-settings--page .embm-settings--status .embm-utfb--account-link .dashicons::before {
    159161    font-size: 18px;
    160162}
    161 .embm-settings--page .embm-settings--status .embm-untappd--deauthorize {
     163.embm-settings--page .embm-settings--status .embm-untappd--deauthorize,
     164.embm-settings--page .embm-settings--status .embm-utfb--disconnect {
    162165    margin-left: 4px;
    163166}
     
    171174    padding: 3px 5px 2px;
    172175}
    173 .embm-settings--page .embm-settings--tab-labs .dashicons-warning {
     176.embm-settings--page .dashicons-warning {
    174177    color: #FFB900;
    175178    cursor: help;
     
    234237
    235238/**
    236  * Style EM Beer Manager labs page
    237  */
    238 .embm-settings--tab-labs .warning {
     239 * Style EM Beer Manager settings tabs
     240 */
     241.embm-settings--page .embm-nav-tab > span {
     242    bottom: 2px;
     243    color: #888;
     244    display: inline-block;
     245    font-size: 10px;
     246    font-weight: normal;
     247    line-height: 14px;
     248    position: relative;
     249}
     250.embm-settings--tab .warning,
     251.embm-metabox--untappd .warning {
    239252    color: red;
    240253    font-weight: bold;
    241254}
    242 .embm-settings--tab-labs .emphasis {
     255.embm-settings--tab .emphasis {
    243256    font-weight: 600;
    244257    text-transform: uppercase;
    245258}
    246 .embm-settings--tab-labs .labs-section {
     259.embm-settings--tab .labs-section {
    247260    color: #23282d;
    248261    font-size: 14px;
    249262    font-weight: 600;
    250263}
    251 .embm-settings--tab-labs .embm-labs--import-select {
     264.embm-settings--tab .embm-labs--import-select {
    252265    margin-right: 10px;
     266}
     267
     268
     269/**
     270 * Style UTFB tab
     271 */
     272#embm-labs-utfb .embm-utfb-section--import-all {
     273    padding-top: 15px;
    253274}
    254275
     
    318339}
    319340.embm-metabox--untappd-checkboxes,
    320 .embm-metabox--untappd-flush {
     341.embm-metabox--untappd-actions {
    321342    float: left;
    322343}
     
    325346    width: 40%;
    326347}
    327 .embm-metabox--untappd-flush {
     348.embm-metabox--untappd-actions {
    328349    max-width: calc(60% - 40px);
    329350}
    330 .embm-metabox--untappd-flush .dashicons {
     351.embm-metabox--untappd-actions .dashicons {
    331352    line-height: 26px;
    332353    color: #FFB900;
     
    335356@media only screen and (max-width: 960px) {
    336357    .embm-metabox--untappd .embm-metabox--untappd-checkboxes,
    337     .embm-metabox--untappd .embm-metabox--untappd-flush {
     358    .embm-metabox--untappd .embm-metabox--untappd-actions {
    338359        float: none;
    339360        width: 100% !important;
    340361    }
    341362}
    342 
     363.embm-metabox--utfb ul {
     364    list-style-type: none;
     365    margin: 0;
     366    padding: 0;
     367}
     368.embm-metabox--utfb ul > li {
     369    display: inline-block;
     370}
     371.embm-metabox--utfb ul > li:not(:last-child)::after {
     372    content: '/';
     373}
    343374
    344375/**
  • em-beer-manager/trunk/assets/css/output.css

    r1584363 r1674966  
    11/**
    2  * Copyright (c) 2013-2016, Erin Morelli.
     2 * Copyright (c) 2013-2017, Erin Morelli.
    33 *
    44 * This program is free software; you can redistribute it and/or
     
    5757    text-decoration: none;
    5858}
    59 .embm-beer .embm-beer--image > .wp-post-image {
     59.embm-beer .embm-beer--image a {
     60    border: 0;
     61    box-shadow: none;
     62    text-decoration: none;
     63}
     64.embm-beer .embm-beer--image .wp-post-image {
    6065    display: block;
    6166    float: left;
     
    6368    width: 150px;
    6469}
    65 .embm-beer .embm-beer--image > img {
     70.embm-beer .embm-beer--image img {
    6671    height: auto;
    6772    width: 150px;
  • em-beer-manager/trunk/assets/css/widgets.css

    r1584363 r1674966  
    11/**
    2  * Copyright (c) 2013-2016, Erin Morelli.
     2 * Copyright (c) 2013-2017, Erin Morelli.
    33 *
    44 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/assets/js/admin.js

    r1584363 r1674966  
    11/**
    2  * Copyright (c) 2013-2016, Erin Morelli.
     2 * Copyright (c) 2013-2017, Erin Morelli.
    33 *
    44 * This program is free software; you can redistribute it and/or
     
    4242        },
    4343        ajax_response = function (response) {
    44             if (typeof response === 'object' && response.hasOwnProperty('redirect')) {
     44            if (response && typeof response === 'object' && response.hasOwnProperty('redirect')) {
    4545                window.location = response.redirect;
    4646            } else {
     
    4848            }
    4949        },
    50         ajax_error = function(spinner) {
     50        ajax_error = function (spinner) {
    5151            spinner.removeClass();
    5252            spinner.addClass('dashicons dashicons-warning');
     
    5656        untappd_check = $('#embm_untappd_check'),
    5757        nav_hidden = (localStorage.embm_hide_settings_nav === 'true'),
     58        utfb_sections = $('tr.embm-utfb-section'),
    5859        hash,
    5960        page,
     
    6263    // Detect Internet Explorer
    6364    function isInternetExplorer() {
    64         var ua = window.navigator.userAgent;
    65         var msie = ua.indexOf('MSIE ');
     65        var ua = window.navigator.userAgent,
     66            msie = ua.indexOf('MSIE ');
    6667        return (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./i));
    6768    }
     
    332333                );
    333334            }
    334         })
    335         .fail(function() {
     335        }).fail(function () {
     336            ajax_error(spinner);
     337        });
     338    });
     339
     340    // Handle beer sync requests
     341    $('.embm-metabox--untappd-sync a').on('click', function (e) {
     342        e.preventDefault();
     343
     344        // Check for user confirmation
     345        if (!window.confirm(embm_settings.sync_confirm_single)) {
     346            return;
     347        }
     348
     349        // Get API root
     350        var api_root = $(this).data('api-root');
     351
     352        // Start spinner
     353        spinner.insertAfter($(this));
     354
     355        // Set AJAX params
     356        ajax_params.action = 'embm-untappd-sync';
     357        ajax_params.sync_type = 1;
     358        ajax_params.post_id = url_params.post;
     359        ajax_params.api_root = api_root;
     360
     361        // Make AJAX request
     362        $.post(ajaxurl, ajax_params, function (response) {
     363            spinner.remove();
     364
     365            // Show error for bad response
     366            if (typeof response === 'string') {
     367                $(e.target).parent().append(
     368                    '<span class="dashicons dashicons-warning" title="' + response + '"></span>'
     369                );
     370            } else {
     371                // Reload page
     372                location.reload();
     373            }
     374        }).fail(function () {
    336375            ajax_error(spinner);
    337376        });
     
    366405                widget.append(error);
    367406            }
    368         })
    369         .fail(function() {
    370             ajax_error(spinner);
    371         });
    372     });
    373 
    374     /* ---- LABS ---- */
     407        }).fail(function () {
     408            ajax_error(spinner);
     409        });
     410    });
     411
     412    /* ---- LABS / UNTAPPD ---- */
    375413
    376414    // Redirect to flush Untappd cache
     
    388426            spinner.remove();
    389427            ajax_response(response);
    390         })
    391         .fail(function() {
     428        }).fail(function () {
    392429            ajax_error(spinner);
    393430        });
     
    417454            spinner.remove();
    418455            ajax_response(response);
    419         })
    420         .fail(function() {
     456        }).fail(function () {
     457            ajax_error(spinner);
     458        });
     459    });
     460
     461    // Handle sync requests
     462    $('a.embm-untappd--sync').on('click', function (e) {
     463        e.preventDefault();
     464
     465        // Check for user confirmation
     466        if (!window.confirm(embm_settings.sync_confirm_plural)) {
     467            return;
     468        }
     469
     470        var api_root = $('#embm-untappd-api-root').val();
     471
     472        // Start spinner
     473        spinner.insertAfter($(this));
     474
     475        // Set AJAX params
     476        ajax_params.action = 'embm-untappd-sync';
     477        ajax_params.sync_type = 2;
     478        ajax_params.api_root = api_root;
     479
     480        // Make AJAX request & reload page
     481        $.post(ajaxurl, ajax_params, function (response) {
     482            spinner.remove();
     483            ajax_response(response);
     484        }).fail(function () {
     485            ajax_error(spinner);
     486        });
     487    });
     488
     489    /* ---- LABS / UTFB ---- */
     490
     491    // Connect a UTFB account
     492    $('a.embm-utfb--connect').on('click', function (e) {
     493        e.preventDefault();
     494
     495        // Start spinner
     496        spinner.insertAfter($(this));
     497
     498        ajax_params.action = 'embm-utfb-connect';
     499        ajax_params.api_key = $('#embm-utfb--apikey').val();
     500        ajax_params.email = $('#embm-utfb--email').val();
     501
     502        // Make AJAX request & reload page
     503        $.post(ajaxurl, ajax_params, function (response) {
     504            spinner.remove();
     505            ajax_response(response);
     506        }).fail(function () {
     507            ajax_error(spinner);
     508        });
     509    });
     510
     511    // Disconnect a UTFB account
     512    $('a.embm-utfb--disconnect').on('click', function (e) {
     513        e.preventDefault();
     514        ajax_params.action = 'embm-utfb-disconnect';
     515        $.post(ajaxurl, ajax_params, ajax_response);
     516    });
     517
     518    // Toggle enable/disable section items
     519    function toggle_utfb_section(section, disable) {
     520        var section_select = section.find('select.embm-utfb--dropdown'),
     521            section_buttons = section.find('button.button');
     522
     523        // Enable items
     524        [section_select, section_buttons].forEach(function (item) {
     525            item.prop('disabled', disable);
     526            item.prop('title', disable ? embm_settings.utfb_section_notice : null);
     527            item.css('cursor', disable ? 'not-allowed' : 'pointer');
     528        });
     529
     530        // Reset selects
     531        if (disable) {
     532            section_select.val('');
     533        }
     534    }
     535
     536    // Load next utfb import dropdown
     537    function load_utfb_dropdown(dropdown) {
     538        var resource = $(dropdown).data('action'),
     539            resource_id = $(dropdown).val();
     540
     541        // Bail if no resource
     542        if (!resource) {
     543            return false;
     544        }
     545
     546        // Reset all child sections
     547        $(dropdown)
     548            .closest('.embm-utfb-section')
     549            .nextAll('.embm-utfb-section')
     550            .each(function (idx, child_section) {
     551                toggle_utfb_section($(child_section), true);
     552            });
     553
     554        // Check for resource ID
     555        if (!resource_id) {
     556            return false;
     557        }
     558
     559        ajax_params.action = 'embm-utfb-dropdown';
     560        ajax_params.resource = resource;
     561        ajax_params.resource_id = resource_id;
     562
     563        // Make AJAX request & reload page
     564        $.post(ajaxurl, ajax_params, function (response) {
     565            if (response.error) {
     566                return;
     567            }
     568
     569            // Find objects for resource
     570            var select = $('#embm-utfb-' + resource + '-id');
     571
     572            // Remove existing options
     573            select.children('option').each(function (idx, option) {
     574                if (idx) {
     575                    $(option).remove();
     576                }
     577            });
     578
     579            // Populate menus select
     580            response.items.forEach(function (item) {
     581                select.append('<option value=' + item.id + '>' + item.name + '</option>');
     582            });
     583
     584            // Enable items
     585            toggle_utfb_section($('tr.embm-utfb-section--' + resource), false);
     586        });
     587    }
     588
     589    // Handle select dropdown changes
     590    $('select.embm-utfb--dropdown').on('change', function (e) {
     591        e.preventDefault();
     592        load_utfb_dropdown(this);
     593
     594        // If this is the location dropdown, update the sync button
     595        if (this.id === 'embm-utfb-location-id') {
     596            var location = $(this),
     597                sync_button = $('button.embm-utfb--sync');
     598
     599            sync_button.prop('disabled', !location.val() ? true : false);
     600            sync_button.css('cursor', !location.val() ? 'not-allowed' : 'pointer');
     601        }
     602    });
     603
     604    // Check for value on page load
     605    utfb_sections.each(function (idx, section) {
     606        var select = $(section).find('select.embm-utfb--dropdown'),
     607            sync_button = $('button.embm-utfb--sync');
     608
     609        // Disable sync button if no location selected
     610        if (!idx && !select.val()) {
     611            sync_button.prop('disabled', true);
     612            sync_button.css('cursor', 'not-allowed');
     613        }
     614
     615        if (select.val() || !idx) {
     616            // Load the dropdown
     617            load_utfb_dropdown(select);
     618        } else {
     619            // Disable items
     620            toggle_utfb_section($(section), true);
     621        }
     622    });
     623
     624    // Import UTFB objects
     625    $('.embm-utfb--import').on('click', function (e) {
     626        e.preventDefault();
     627
     628        // Get import data
     629        var resources = {},
     630            resource = $(this).data('resource'),
     631            resource_types = embm_settings.utfb_resources,
     632            import_all = $(this).parent().hasClass('embm-utfb-section--import-all');
     633
     634        // Start spinner
     635        spinner.insertAfter($(this));
     636
     637        // Get resource IDs
     638        resource_types.forEach(function (resource_type) {
     639            resources[resource_type] = $('#embm-utfb-' + resource_type + '-id').val();
     640        });
     641
     642        // Set up ajax action
     643        ajax_params.action = 'embm-utfb-import';
     644        ajax_params.resource = resource;
     645        ajax_params.resources = resources;
     646        ajax_params.import_all = import_all;
     647
     648        // Make AJAX request & reload page
     649        $.post(ajaxurl, ajax_params, function (response) {
     650            spinner.remove();
     651            ajax_response(response);
     652        }).fail(function () {
     653            ajax_error(spinner);
     654        });
     655    });
     656
     657    // Sync UTFB objects
     658    $('button.embm-utfb--sync').on('click', function (e) {
     659        e.preventDefault();
     660
     661        // Check for user confirmation
     662        if (!window.confirm(embm_settings.sync_confirm_utfb)) {
     663            return;
     664        }
     665
     666        // Get import data
     667        var resources = {},
     668            resource_types = ['location', 'menu', 'section', 'beer'];
     669
     670        // Start spinner
     671        spinner.insertAfter($(this));
     672
     673        // Get resource IDs
     674        resource_types.forEach(function (resource_type) {
     675            resources[resource_type] = $('#embm-utfb-' + resource_type + '-id').val();
     676        });
     677
     678        // Set up ajax action
     679        ajax_params.action = 'embm-utfb-sync';
     680        ajax_params.resource = 'menu';
     681        ajax_params.resources = resources;
     682        ajax_params.import_all = true;
     683
     684        // Make AJAX request & reload page
     685        $.post(ajaxurl, ajax_params, function (response) {
     686            spinner.remove();
     687            ajax_response(response);
     688        }).fail(function () {
     689            ajax_error(spinner);
     690        });
     691    });
     692
     693    // Redirect to flush UTFB cache
     694    $('a.embm-utfb--flush').on('click', function (e) {
     695        e.preventDefault();
     696
     697        // Start spinner
     698        spinner.insertAfter($(this));
     699
     700        // Set AJAX params
     701        ajax_params.action = 'embm-utfb-flush';
     702
     703        // Make AJAX request & reload page
     704        $.post(ajaxurl, ajax_params, function (response) {
     705            spinner.remove();
     706            ajax_response(response);
     707        }).fail(function () {
    421708            ajax_error(spinner);
    422709        });
  • em-beer-manager/trunk/em-beer-manager.php

    r1647727 r1674966  
    33 * Plugin Name: EM Beer Manager
    44 * Plugin URI: https://www.erinmorelli.com/projects/em-beer-manager
    5  * Description: Catalog and display your beers with WordPress. Integrates very simply with Untappd for individual beer check-ins. Great for everyone from home brewers to professional breweries!
    6  * Version: 3.0.5
     5 * Description: Manage and display your beers with WordPress. Integrates simply with Untappd and Untappd for Business. Great for everyone from home brewers to professional breweries!
     6 * Version: 3.1.0
    77 * Author: Erin Morelli
    88 * Author URI: https://www.erinmorelli.com/
     
    1414
    1515/**
    16  * Copyright (c) 2013-2016, Erin Morelli.
     16 * Copyright (c) 2013-2017, Erin Morelli.
    1717 *
    1818 * This program is free software; you can redistribute it and/or
     
    4949{
    5050    // Set current version
    51     $embm_curr_version = '3.0.5';
     51    $embm_curr_version = '3.1.0';
    5252
    5353    // Define version key name
  • em-beer-manager/trunk/includes/admin/embm-admin-actions.php

    r1584363 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    147147
    148148    // Flush the transient cache
    149     EMBM_Admin_Untappd_flush();
     149    EMBM_Admin_Untappd_flush(EMBM_UNTAPPD_CACHE);
    150150
    151151    // Send response
     
    235235    // Set up response
    236236    $response = array(
    237         'redirect' => get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'success', 2, 'labs'))
     237        'redirect' => get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'success', 2, 'untappd'))
    238238    );
    239239
     
    243243    // Check for error
    244244    if (!is_object($brewery)) {
    245         $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 1, 'labs'));
     245        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
    246246        wp_send_json($response);
    247247        return;
     
    253253    // Check for error
    254254    if (!is_array($beer_list)) {
    255         $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 1, 'labs'));
     255        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
    256256        wp_send_json($response);
    257257        return;
     
    287287            // Check for error
    288288            if (!is_object($beer)) {
    289                 $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 1, 'labs'));
     289                $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
    290290                break;
    291291            }
     
    302302        // Check for errors
    303303        if ($has_errors) {
    304             $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 5, 'labs'));
     304            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 5, 'untappd'));
    305305        }
    306306        break;
     
    327327        // Check for error
    328328        if (!is_object($beer)) {
    329             $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 1, 'labs'));
     329            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
    330330            break;
    331331        }
     
    338338            $response['redirect'] = $res;
    339339        } else {
    340             $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'success', 1, 'labs'));
     340            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'success', 1, 'untappd'));
    341341        }
    342342        break;
     
    360360            // Check for error
    361361            if (!is_object($beer)) {
    362                 $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 1, 'labs'));
     362                $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
    363363                break;
    364364            }
     
    375375        // Check for errors
    376376        if ($has_errors) {
    377             $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 5, 'labs'));
     377            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 5, 'untappd'));
    378378        }
    379379        break;
     
    382382    default:
    383383        // Setup return URL
    384         $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'error', 4, 'labs'));
     384        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 4, 'untappd'));
    385385    }
    386386
     
    391391// Add flush beer action to AJAX
    392392add_action('wp_ajax_embm-untappd-import', 'EMBM_Admin_Actions_Untappd_import');
     393
     394/**
     395 * Sync beer data from Untappd to WP
     396 *
     397 * @return void
     398 */
     399function EMBM_Admin_Actions_Untappd_sync()
     400{
     401    // Check AJAX referrer
     402    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     403
     404    // Get sync vars
     405    $sync_type = intval($_POST['sync_type']);
     406    $api_root = $_POST['api_root'];
     407
     408    // Set up response
     409    $response = array(
     410        'redirect' => get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'sync', 'success', 1, 'untappd'))
     411    );
     412
     413    // Handle sync types
     414    switch ($sync_type) {
     415
     416    // Sync specific beer
     417    case 1:
     418        // Get post id
     419        $post_id = $_POST['post_id'];
     420
     421        // Make sure we have an ID
     422        if (!$post_id) {
     423            wp_die();
     424        }
     425
     426        // Get post from ID
     427        $post = get_post($post_id);
     428
     429        // Get beer from API
     430        $beer = EMBM_Admin_Untappd_Beer_get($api_root, $post->embm_untappd);
     431
     432        // Check for error
     433        if (!is_object($beer)) {
     434            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
     435            break;
     436        }
     437
     438        // Run import with brewery check
     439        $res = EMBM_Admin_Untappd_sync($post->ID, $beer);
     440
     441        // Check response
     442        if (!is_null($res)) {
     443            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'sync', 'error', 1, 'untappd'));
     444        } else {
     445            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'sync', 'success', 2, 'untappd'));
     446        }
     447        break;
     448
     449    // Sync all beers
     450    case 2:
     451        // Set error tracker
     452        $has_errors = false;
     453
     454        // Get all the Untappd beers in the database
     455        $beer_list = get_posts(
     456            array(
     457                'post_type'   => 'embm_beer',
     458                'numberposts' => -1
     459            )
     460        );
     461
     462        // Iteratively add beers
     463        foreach ($beer_list as $item) {
     464            // Check for Untappd ID
     465            if ($item->embm_untappd == '') {
     466                continue;
     467            }
     468
     469            // Get beer from API
     470            $beer = EMBM_Admin_Untappd_Beer_get($api_root, $item->embm_untappd);
     471
     472            // Check for error
     473            if (!is_object($beer)) {
     474                $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'import', 'error', 1, 'untappd'));
     475                break;
     476            }
     477
     478            // Run import
     479            $res = EMBM_Admin_Untappd_sync($item->ID, $beer);
     480
     481            // Check response
     482            if (!is_null($res)) {
     483                $has_errors = true;
     484            }
     485        }
     486
     487        // Check for errors
     488        if ($has_errors) {
     489            $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'sync', 'error', 2, 'untappd'));
     490        }
     491        break;
     492
     493    // Fallback
     494    default:
     495        // Setup return URL
     496        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UNTAPPD_RETURN_URL, 'sync', 'error', 1, 'untappd'));
     497    }
     498
     499    // Send response
     500    wp_send_json($response);
     501}
     502
     503// Add flush beer action to AJAX
     504add_action('wp_ajax_embm-untappd-sync', 'EMBM_Admin_Actions_Untappd_sync');
     505
     506/**
     507 * Connect to a UTFB account
     508 *
     509 * @return void
     510 */
     511function EMBM_Admin_Actions_Utfb_connect()
     512{
     513    // Check AJAX referrer
     514    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     515
     516    // Get POST data
     517    $credentials = array(
     518        'apikey'  => $_POST['api_key'],
     519        'email'   => $_POST['email']
     520    );
     521
     522    // Test for validity
     523    $is_valid = EMBM_Admin_Utfb_validate($credentials);
     524
     525    // Respond to validity
     526    if ($is_valid) {
     527        // Store credentials
     528        update_option('embm_utfb_credentials', $credentials);
     529
     530        // Set up redirect URL
     531        $redirect_url = get_admin_url(null, sprintf(EMBM_UTFB_RETURN_URL, 'success', 1, 'utfb'));
     532    } else {
     533        // Set up redirect URL
     534        $redirect_url = get_admin_url(null, sprintf(EMBM_UTFB_RETURN_URL, 'error', 1, 'utfb'));
     535    }
     536
     537    // Set up response
     538    $response = array(
     539        'redirect' => $redirect_url
     540    );
     541
     542    // Send response
     543    wp_send_json($response);
     544}
     545
     546// Add UTFB connect action to AJAX
     547add_action('wp_ajax_embm-utfb-connect', 'EMBM_Admin_Actions_Utfb_connect');
     548
     549/**
     550 * Disconnect to a UTFB account
     551 *
     552 * @return void
     553 */
     554function EMBM_Admin_Actions_Utfb_disconnect()
     555{
     556    // Check AJAX referrer
     557    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     558
     559    // Remove connected account information
     560    delete_option('embm_utfb_credentials');
     561
     562    // Flush caches
     563    EMBM_Admin_Untappd_flush(EMBM_UTFB_CACHE);
     564
     565    // Send response
     566    wp_die();
     567}
     568
     569// Add UTFB connect action to AJAX
     570add_action('wp_ajax_embm-utfb-disconnect', 'EMBM_Admin_Actions_Utfb_disconnect');
     571
     572/**
     573 * Get UTFB menus for a locations
     574 *
     575 * @return void
     576 */
     577function EMBM_Admin_Actions_Utfb_dropdown()
     578{
     579    // Check AJAX referrer
     580    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     581
     582    // Get POST data
     583    $resource = $_POST['resource'];
     584    $resource_id = $_POST['resource_id'];
     585
     586    // Get credentials
     587    $auth = get_option('embm_utfb_credentials');
     588
     589    // Get resource map
     590    $resource_map = $GLOBALS['EMBM_UTFB_RESOURCE_MAP'];
     591
     592    // Return error if resource does not exist
     593    if (!array_key_exists($resource, $resource_map)) {
     594        wp_send_json_error();
     595        return;
     596    }
     597
     598    // Get correct resource function from map
     599    $resource_func = $resource_map[$resource]['plural'];
     600
     601    // Get items from resource
     602    $items = $resource_func($auth, $resource_id);
     603
     604    // Check response
     605    if (is_null($items)) {
     606        wp_send_json_error();
     607        return;
     608    }
     609
     610    // Set up response
     611    $response = array(
     612        'items' => $items
     613    );
     614
     615    // Send response
     616    wp_send_json($response);
     617}
     618
     619// Add UTFB menus action to AJAX
     620add_action('wp_ajax_embm-utfb-dropdown', 'EMBM_Admin_Actions_Utfb_dropdown');
     621
     622/**
     623 * Import objects from UTFB
     624 *
     625 * @return void
     626 */
     627function EMBM_Admin_Actions_Utfb_import()
     628{
     629    // Check AJAX referrer
     630    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     631
     632    // Get POST data
     633    $resource = $_POST['resource'];
     634    $resources = $_POST['resources'];
     635    $import_all = ($_POST['import_all'] == 'true') ? true : false;
     636
     637    // Get credentials
     638    $auth = get_option('embm_utfb_credentials');
     639
     640    // Get UTFB objects to import
     641    $objects = EMBM_Admin_Utfb_resources($auth, $resources, $resource, $import_all);
     642
     643    // Run import
     644    $error_code = EMBM_Admin_Utfb_import($objects);
     645
     646    // Check response
     647    if ($error_code !== 0) {
     648        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UTFB_RETURN_URL, 'error', $error_code, 'utfb'));
     649    } else {
     650        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UTFB_RETURN_URL, 'success', 2, 'utfb'));
     651    }
     652
     653    // Send response
     654    wp_send_json($response);
     655}
     656
     657// Add UTFB import action to AJAX
     658add_action('wp_ajax_embm-utfb-import', 'EMBM_Admin_Actions_Utfb_import');
     659
     660/**
     661 * Flush the UTFB cache
     662 *
     663 * @return void
     664 */
     665function EMBM_Admin_Actions_Utfb_flush()
     666{
     667    // Check AJAX referrer
     668    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     669
     670    // Flush the UTFB cache
     671    EMBM_Admin_Untappd_flush(EMBM_UTFB_CACHE);
     672
     673    // Send response
     674    wp_die();
     675}
     676
     677// Add flush beer action to AJAX
     678add_action('wp_ajax_embm-utfb-flush', 'EMBM_Admin_Actions_Utfb_flush');
     679
     680/**
     681 * Sync data from UTFB with existing beers
     682 *
     683 * @return void
     684 */
     685function EMBM_Admin_Actions_Utfb_sync()
     686{
     687    // Check AJAX referrer
     688    check_ajax_referer(EMBM_AJAX_NONCE, '_nonce');
     689
     690    // Get POST data
     691    $resource = $_POST['resource'];
     692    $resources = $_POST['resources'];
     693    $import_all = ($_POST['import_all'] == 'true') ? true : false;
     694
     695    // Get credentials
     696    $auth = get_option('embm_utfb_credentials');
     697
     698    // Get UTFB objects to import
     699    $objects = EMBM_Admin_Utfb_resources($auth, $resources, $resource, $import_all);
     700
     701    // Run sync
     702    $error_code = EMBM_Admin_Utfb_sync($objects);
     703
     704    // Check response
     705    if ($error_code !== 0) {
     706        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UTFB_RETURN_URL, 'error', $error_code, 'utfb'));
     707    } else {
     708        $response['redirect'] = get_admin_url(null, sprintf(EMBM_UTFB_RETURN_URL, 'success', 3, 'utfb'));
     709    }
     710
     711    // Send response
     712    wp_send_json($response);
     713}
     714
     715// Add flush beer action to AJAX
     716add_action('wp_ajax_embm-utfb-sync', 'EMBM_Admin_Actions_Utfb_sync');
  • em-beer-manager/trunk/includes/admin/embm-admin-footer.php

    r1647727 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    3737            target="_blank"
    3838        >
    39             <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="<?php _e('Donate', 'embm'); ?>" border="0" />
     39            <img src="<?php echo EMBM_PLUGIN_URL; ?>assets/img/donate.png" alt="<?php _e('Donate', 'embm'); ?>" border="0" />
    4040        </a>
    4141    </p>
  • em-beer-manager/trunk/includes/admin/embm-admin-notices.php

    r1584363 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    2020 */
    2121
     22$SUCCESS_TITLE = __('Success!', 'embm');
     23$ERROR_TITLE   = __('ERROR', 'embm') . ':';
     24$WARNING_TITLE = __('WARNING', 'embm') . ':';
     25
    2226// Map of notices
    2327$GLOBALS['EMBM_NOTICE_MAP'] = array(
     
    2529        '1' => array(
    2630            'type'      => 'updated',
    27             'title'     => __('Success!', 'embm'),
     31            'title'     => $SUCCESS_TITLE,
    2832            'message'   => __('Your beer styles have been restored.', 'embm')
    2933        )
     
    3236        '1' => array(
    3337            'type'      => 'updated',
    34             'title'     => __('Success!', 'embm'),
     38            'title'     => $SUCCESS_TITLE,
    3539            'message'   => __('Your beer has been imported from Untappd.', 'embm')
    3640        ),
    3741        '2' => array(
    3842            'type'      => 'updated',
    39             'title'     => __('Success!', 'embm'),
     43            'title'     => $SUCCESS_TITLE,
    4044            'message'   => __('Your beers have been imported from Untappd.', 'embm')
    4145        )
     
    4448        '1' => array(
    4549            'type'      => 'error',
    46             'title'     => __('ERROR', 'embm') . ':',
     50            'title'     => $ERROR_TITLE,
    4751            'message'   => __('There was a problem! You may have reached your API token\'s rate limit for the hour. Please try again later.', 'embm')
    4852        ),
    4953        '2' => array(
    5054            'type'      => 'error',
    51             'title'     => __('ERROR', 'embm') . ':',
     55            'title'     => $ERROR_TITLE,
    5256            'message'   => __('There was a problem during the import! The beer you specified was not found on Untappd.', 'embm')
    5357        ),
    5458        '3' => array(
    5559            'type'      => 'error',
    56             'title'     => __('ERROR', 'embm') . ':',
     60            'title'     => $ERROR_TITLE,
    5761            'message'   => __('This beer does not belong to your brewery! You can only import beers that are owned by your Untappd brewery account.', 'embm')
    5862        ),
    5963        '4' => array(
    6064            'type'      => 'error',
    61             'title'     => __('ERROR', 'embm') . ':',
     65            'title'     => $ERROR_TITLE,
    6266            'message'   => __('There was a problem during the import! Please try again later.', 'embm')
    6367        ),
    6468        '5' => array(
    6569            'type'      => 'warning',
    66             'title'     => __('WARNING', 'embm') . ':',
     70            'title'     => $WARNING_TITLE,
    6771            'message'   => __('There was a problem during the import! One or more beers was not imported. Please try again later.', 'embm')
    6872        )
    6973    ),
     74    'sync-success' => array(
     75        '1' => array(
     76            'type'      => 'updated',
     77            'title'     => $SUCCESS_TITLE,
     78            'message'   => __('Your beers have been updated from Untappd.', 'embm')
     79        ),
     80        '2' => array(
     81            'type'      => 'updated',
     82            'title'     => $SUCCESS_TITLE,
     83            'message'   => __('Your beer has been updated from Untappd.', 'embm')
     84        )
     85    ),
     86    'sync-error' => array(
     87        '1' => array(
     88            'type'      => 'error',
     89            'title'     => $ERROR_TITLE,
     90            'message'   => __('There was a problem during the sync! Please try again later.', 'embm')
     91        ),
     92        '2' => array(
     93            'type'      => 'warning',
     94            'title'     => $WARNING_TITLE,
     95            'message'   => __('There was a problem during the sync! One or more beers were not updated. Please try again later.', 'embm')
     96        )
     97    ),
    7098    'save-error' => array(
    7199        '1' => array(
    72100            'type'      => 'error',
    73             'title'     => __('ERROR', 'embm') . ':',
     101            'title'     => $ERROR_TITLE,
    74102            'message'   => __('There was a problem saving your beer\'s Untappd data!', 'embm').' '.
    75103                __('You may have reached your API token\'s rate limit for the hour. Please try again later.', 'embm')
     
    79107        '1' => array(
    80108            'type'      => 'error',
    81             'title'     => __('ERROR', 'embm') . ':',
     109            'title'     => $ERROR_TITLE,
    82110            'message'   => __('There was a problem retrieving check-in data from Untappd!', 'embm').' '.
    83111                __('Please try again later.', 'embm')
     
    85113        '2' => array(
    86114            'type'      => 'error',
    87             'title'     => __('ERROR', 'embm') . ':',
     115            'title'     => $ERROR_TITLE,
    88116            'message'   => __('There was a problem refreshing check-in data from Untappd!', 'embm').' '.
    89117                __('Please try again later.', 'embm')
     118        )
     119    ),
     120    'utfb-error' => array(
     121        '1' => array(
     122            'type'      => 'error',
     123            'title'     => $ERROR_TITLE,
     124            'message'   => __('There was a problem connecting your Untappd for Business account! Please try again later.', 'embm')
     125        ),
     126        '2' => array(
     127            'type'      => 'error',
     128            'title'     => $ERROR_TITLE,
     129            'message'   => __('There was a problem during the import! Please try again later.', 'embm')
     130        ),
     131        '3' => array(
     132            'type'      => 'warning',
     133            'title'     => $WARNING_TITLE,
     134            'message'   => __('There was a problem during the import! One or more beers were not imported. Please try again later.', 'embm')
     135        ),
     136        '4' => array(
     137            'type'      => 'warning',
     138            'title'     => $WARNING_TITLE,
     139            'message'   => __('There was a problem during the sync! One or more beers were not updated. Please try again later.', 'embm')
     140        )
     141    ),
     142    'utfb-success' => array(
     143        '1' => array(
     144            'type'      => 'updated',
     145            'title'     => $SUCCESS_TITLE,
     146            'message'   => __('Your Untappd for Business account has been connected.', 'embm')
     147        ),
     148        '2' => array(
     149            'type'      => 'updated',
     150            'title'     => $SUCCESS_TITLE,
     151            'message'   => __('Your beers have been imported from your Untappd for Business account.', 'embm')
     152        ),
     153        '3' => array(
     154            'type'      => 'updated',
     155            'title'     => $SUCCESS_TITLE,
     156            'message'   => __('Your beers have been synced with your Untappd for Business menus.', 'embm')
    90157        )
    91158    )
  • em-beer-manager/trunk/includes/admin/embm-admin-settings.php

    r1586946 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    2222// Import additional admin functions
    2323require EMBM_PLUGIN_DIR.'includes/admin/embm-admin-notices.php';
    24 require EMBM_PLUGIN_DIR.'includes/admin/embm-admin-authorize.php';
     24require EMBM_PLUGIN_DIR.'includes/admin/integrations/embm-integrations-authorize.php';
    2525
    2626// Set global admin page object
     
    596596function EMBM_Admin_Settings_page()
    597597{
     598    // Get tabs data
     599    $tabs = array(
     600        array(
     601            'id'      => 'untappd',
     602            'name'    => sprintf('%s <span>%s</span>', __('Untappd Import', 'embm'), __('Labs', 'embm')),
     603            'hide'    => EMBM_Core_Beer_disabled()
     604        ),
     605        array(
     606            'id'      => 'utfb',
     607            'name'    => sprintf('%s <span>%s</span>', __('Untappd for Business Import', 'embm'), __('Labs', 'embm')),
     608            'hide'    => EMBM_Core_Beer_disabled()
     609        ),
     610        array(
     611            'id'      => 'usage',
     612            'name'    => __('Usage', 'embm'),
     613            'hide'    => false
     614        )
     615    );
     616
    598617    // Get settings page sections
    599618    global $wp_settings_sections;
     
    618637    <div id="embm-settings--tabs" class="embm-settings--tabs-wrapper">
    619638        <ul class="nav-tab-wrapper">
    620             <li><a href="#settings" class="embm-nav-tab nav-tab nav-tab-active nav-tab-settings"><?php _e('Settings', 'embm'); ?></a></li>
    621             <li><a href="#labs" class="embm-nav-tab nav-tab nav-tab-labs"><?php _e('Labs', 'embm'); ?></a></li>
    622             <li><a href="#usage" class="embm-nav-tab nav-tab nav-tab-usage"><?php _e('Usage', 'embm'); ?></a></li>
     639            <li>
     640                <a href="#settings" class="embm-nav-tab nav-tab nav-tab-active nav-tab-settings">
     641                    <?php _e('Settings', 'embm'); ?>
     642                </a>
     643            </li>
     644            <?php foreach ($tabs as $tab) : ?>
     645                <?php if (!$tab['hide']) : ?>
     646                    <li>
     647                        <a href="#<?php echo $tab['id']; ?>" class="embm-nav-tab nav-tab nav-tab-<?php echo $tab['id']; ?>">
     648                            <?php echo $tab['name']; ?>
     649                        </a>
     650                    </li>
     651                <?php endif; ?>
     652            <?php endforeach; ?>
    623653        </ul>
    624654
     
    649679        </div>
    650680
    651         <div id="labs" class="embm-settings--tab-labs">
    652             <?php include_once EMBM_PLUGIN_DIR.'includes/admin/tabs/embm-tabs-labs.php'; ?>
    653         </div>
    654 
    655         <div id="usage" class="embm-settings--tab-usage">
    656             <?php include_once EMBM_PLUGIN_DIR.'includes/admin/tabs/embm-tabs-usage.php'; ?>
    657         </div>
     681        <?php foreach ($tabs as $tab) : ?>
     682            <?php if (!$tab['hide']) : ?>
     683                <div id="<?php echo $tab['id']; ?>" class="embm-settings--tab embm-settings--tab-<?php echo $tab['id']; ?>">
     684                    <?php include_once EMBM_PLUGIN_DIR.'includes/admin/tabs/embm-tabs-'.$tab['id'].'.php'; ?>
     685                </div>
     686            <?php endif; ?>
     687        <?php endforeach; ?>
    658688    </div>
    659689
  • em-beer-manager/trunk/includes/admin/tabs/embm-tabs-labs.php

    r1586946 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    3737
    3838<hr />
    39 
    40 <?php
    41 
    42 // Load Untappd labs page
    43 if (!EMBM_Core_Beer_disabled()) {
    44     echo '<h2>'.__('Import from Untappd', 'embm').'</h2>';
    45     include_once EMBM_PLUGIN_DIR.'includes/admin/labs/embm-labs-untappd.php';
    46 } else {
    47     echo '<h2>'.__('No Labs features are available right now!', 'embm').'</h2>';
    48 }
  • em-beer-manager/trunk/includes/admin/tabs/embm-tabs-usage.php

    r1584318 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/includes/embm-admin.php

    r1584363 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    2121
    2222// Include additional Admin functions
    23 require EMBM_PLUGIN_DIR.'includes/admin/embm-admin-untappd.php';
     23require EMBM_PLUGIN_DIR.'includes/admin/integrations/embm-integrations-untappd.php';
     24require EMBM_PLUGIN_DIR.'includes/admin/integrations/embm-integrations-utfb.php';
    2425require EMBM_PLUGIN_DIR.'includes/admin/embm-admin-actions.php';
    2526require EMBM_PLUGIN_DIR.'includes/admin/embm-admin-settings.php';
     
    5455    $ajax_nonce = wp_create_nonce(EMBM_AJAX_NONCE);
    5556
     57    // Set sync confirmation text
     58    $confirm = __('Are you sure you want to continue?', 'embm');
     59    $sconfirm = __('WARNING: This will override any changes you have made to %s. %s', 'embm');
     60    $uconfirm = __('WARNING: This will override any custom menu associations you have made. %s', 'embm');
     61
    5662    // Share EMBM settings with admin script
    5763    wp_localize_script(
     
    6268              'plugin_url'          => EMBM_PLUGIN_URL,
    6369              'options'             => get_option('embm_options'),
    64               'error'               => __('There was a problem with your request! Please try again later.', 'embm')
     70              'error'               => __('There was a problem with your request! Please try again later.', 'embm'),
     71              'utfb_resources'      => array_keys($GLOBALS['EMBM_UTFB_RESOURCE_MAP']),
     72              'utfb_section_notice' => __('Select an option from the dropdown in the section above to enable.', 'embm'),
     73              'sync_confirm_plural' => sprintf($sconfirm, __('your imported beers', 'embm'), $confirm),
     74              'sync_confirm_single' => sprintf($sconfirm, __('this beer', 'embm'), $confirm),
     75              'sync_confirm_utfb'   => sprintf($uconfirm, $confirm)
    6576        )
    6677    );
     
    277288    $screen->add_help_tab($default_help['untappd_id']);
    278289    $screen->add_help_tab($default_help['untappd_limit']);
     290
     291    // Untappd for Business help tab
     292    $screen->add_help_tab(
     293        array(
     294            'id'      => 'embm-utfb-integration',
     295            'title'   => __('Untappd for Business Integration', 'embm'),
     296            'content' => '<p><strong>'.
     297                __('Why is an Untappd account required in addition to an UTFB account?', 'embm').
     298                '</strong></p><p>'.
     299                __('Untappd for Business (UTFB) account credentials do not work with Untappd\'s API. In order to link Untappd data to beers imported from UTFB, Untappd API access is also needed.', 'embm').
     300                '</p><p>'.
     301                __('An Untappd brewery account is not required to work with UTFB. A standard user account will work.', 'embm').
     302                '</p><p><strong>'.
     303                __('Where do I find my API key?', 'embm').
     304                '</strong></p><p>'.
     305                sprintf(
     306                    __('You can find your API key under the "API Access Tokens" section %s.', 'embm'),
     307                    sprintf(
     308                        '<a href="https://business.untappd.com/api_tokens" target="_blank">%s</a>',
     309                        __('here', 'embm')
     310                    )
     311                ).
     312                '</p>'
     313        )
     314    );
    279315
    280316    // Settings FAQ help tab
  • em-beer-manager/trunk/includes/embm-core.php

    r1584363 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    5151        'capability_type'       => 'post',
    5252        'hierarchical'          => false,
    53         'taxonomies'            => array('embm_style', 'embm_group'),
     53        'taxonomies'            => array('embm_style', 'embm_group', 'embm_menu'),
    5454        'has-archive'           => true,
    5555        'menu_position'         => 5,
     
    483483// Loads the custom Group taxonomy
    484484add_action('init', 'EMBM_Core_group', 0);
     485
     486/**
     487 * Loads the custom EMBM menu taxonomy
     488 *
     489 * @return void
     490 */
     491function EMBM_Core_menu()
     492{
     493    // Set custom taxonomy terminology
     494    $labels = array(
     495        'name'                          => __('Menus', 'embm'),
     496        'singular_name'                 => __('Menu', 'embm'),
     497        'search_items'                  => __('Search Menus', 'embm'),
     498        'all_items'                     => __('All Menus', 'embm'),
     499        'edit_item'                     => __('Edit Menu', 'embm'),
     500        'update_item'                   => __('Update Menu', 'embm'),
     501        'add_new_item'                  => __('Add New Menu', 'embm'),
     502        'new_item_name'                 => __('New Menu Name', 'embm'),
     503        'popular_items'                 => __('Popular Menus', 'embm'),
     504        'choose_from_most_used'         => __('Choose from the most used menus', 'embm'),
     505        'separate_items_with_commas'    => __('Separate menus with commas', 'embm'),
     506        'add_or_remove_items'           => __('Add or remove menus', 'embm'),
     507        'menu_name'                     => __('Menus', 'embm')
     508    );
     509
     510    // Set up custom taxonomy options
     511    $args = array(
     512        'hierarchical'          => true,
     513        'labels'                => $labels,
     514        'show_ui'               => true,
     515        'show_admin_column'     => true,
     516        'query_var'             => true,
     517        'rewrite'               => array(
     518            'slug'              => 'beer/menu',
     519            'with_front'        => false
     520        ),
     521        'show_in_rest'          => true,
     522        'rest_base'             => 'embm_menus',
     523        'rest_controller_class' => 'WP_REST_Terms_Controller',
     524    );
     525
     526    // Register the group taxonomy with the EMBM custom post type
     527    register_taxonomy('embm_menu', array('embm_beer'), $args);
     528}
     529
     530// Loads the custom Group taxonomy
     531add_action('init', 'EMBM_Core_menu', 0);
    485532
    486533/**
     
    777824{
    778825    // Get list of errors
    779     $errors = get_transient($GLOBALS['EMBM_UNTAPPD_CACHE']['save_errors']);
     826    $errors = get_transient($GLOBALS[EMBM_UNTAPPD_CACHE]['save_errors']);
    780827    if (!$errors) {
    781828        return;
     
    803850
    804851    // Remove the errors from cache
    805     delete_transient($GLOBALS['EMBM_UNTAPPD_CACHE']['save_errors']);
     852    delete_transient($GLOBALS[EMBM_UNTAPPD_CACHE]['save_errors']);
    806853}
    807854
  • em-beer-manager/trunk/includes/embm-output.php

    r1584774 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    4444
    4545    // Beer title
    46     if (is_page() || is_archive() || is_tax('embm_group')) {
     46    if (is_page() || is_archive() || is_tax('embm_group') || is_tax('embm_menu')) {
    4747        $output .= '<a href="'.get_permalink($beer_id).'" title="'.get_the_title($beer_id).'">';
    4848        $output .= '<span class="embm-beer--header-title">'.get_the_title($beer_id).'</span>';
     
    6969        if (get_the_post_thumbnail($beer_id) != '') {
    7070            $output .= '<div class="embm-beer--image">'."\n";
     71            $output .= '<a href="'.get_permalink($beer_id).'">'."\n";
    7172            $output .= get_the_post_thumbnail($beer_id, 'full')."\n";
     73            $output .= '</a>'."\n";
    7274            $output .= '</div>'."\n";
    7375        }
     
    98100
    99101    // Set read more link
    100     if ((is_tax('embm_style') || is_archive()) && !is_tax('embm_group')) {
     102    if ((is_tax('embm_style') || is_archive()) && !is_tax('embm_group') && !is_tax('embm_menu')) {
    101103        $output .= ' <a class="read-more" href="'.get_permalink($beer_id).'">';
    102104        $output .= __('More', 'embm').'...';
     
    156158    $output .= '</div>'."\n";
    157159
     160    // Add hook-able content filter
     161    $output = apply_filters('embm_beer_filter_beer', $output);
     162
    158163    // Return HTML content
    159164    return $output;
     
    199204    $output .= '<img src="'.$untap_img.'" alt="'.$untap_title.'" border="0" />';
    200205    $output .= '</a></div>';
     206
     207    // Add hook-able content filter
     208    $output = apply_filters('embm_beer_filter_untappd', $output);
    201209
    202210    // Return HTML content
     
    282290    $output .= '</div>'."\n";
    283291
     292    // Add hook-able content filter
     293    $output = apply_filters('embm_beer_filter_profile', $output);
     294
    284295    // Return HTML content
    285296    return $output;
     
    343354    $output .= '</div>'."\n";
    344355
     356    // Add hook-able content filter
     357    $output = apply_filters('embm_beer_filter_extras', $output);
     358
    345359    // Return HTML content
    346360    return $output;
     
    399413    $output .= EMBM_Output_Rating_styles();
    400414    $output .= '</div>'."\n";
     415
     416    // Add hook-able content filter
     417    $output = apply_filters('embm_beer_filter_rating', $output);
    401418
    402419    // Return HTML output
     
    442459        }
    443460    }
     461
     462    // Add hook-able content filter
     463    $stars = apply_filters('embm_beer_filter_rating_stars', $stars);
    444464
    445465    // Return HTML output
     
    469489    $styles .= '</style>';
    470490
     491    // Add hook-able content filter
     492    $styles = apply_filters('embm_beer_filter_rating_styles', $styles);
     493
    471494    // Return CSS content
    472495    return $styles;
     
    577600    $output .= '</div>'."\n";
    578601
     602    // Add hook-able content filter
     603    $output = apply_filters('embm_beer_filter_reviews', $output);
     604
    579605    // Return HTML output
    580606    return $output;
     
    652678    // End review
    653679    $output .= '</div>'."\n";
     680
     681    // Add hook-able content filter
     682    $output = apply_filters('embm_beer_filter_review_content', $output);
    654683
    655684    // Return HTML output
  • em-beer-manager/trunk/includes/embm-upgrades.php

    r1586946 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/includes/metaboxes/embm-metabox-extras.php

    r1584318 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/includes/metaboxes/embm-metabox-profile.php

    r1584318 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/includes/metaboxes/embm-metabox-untappd.php

    r1584363 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    6161
    6262    // Set custom post data values
     63    $utfb_id = isset($beer_entry['embm_utfb']) ? esc_attr($beer_entry['embm_utfb'][0]) : '';
    6364    $untappd_id = isset($beer_entry['embm_untappd']) ? esc_attr($beer_entry['embm_untappd'][0]) : '';
    6465    $hide_rating = isset($beer_entry['embm_hide_rating']) ? esc_attr($beer_entry['embm_hide_rating'][0]) : '';
     
    7172    $beer_found = false;
    7273    $show_api_error = (null !== $untappd_data && !is_object($untappd_data));
     74    $utfb_data = null;
     75
     76    // Check for UTFB account
     77    if ($utfb_id !== '') {
     78        $utfb_data = EMBM_Core_Beer_attr($post->ID, 'utfb_data');
     79
     80        // Check for matching Untappd id
     81        if (property_exists($utfb_data, 'untappd_id') && $utfb_data->untappd_id == $untappd_id) {
     82            $beer_found = true;
     83        }
     84
     85        // Get the UTFB menus
     86        $menus = wp_get_object_terms($post->ID, 'embm_menu', array('order' => 'DESC'));
     87    }
    7388
    7489    // Get token
     
    146161                    data-value="<?php echo $untappd_id; ?>"
    147162                    value="<?php echo $untappd_id; ?>"
    148                 <?php if ($is_brewery && $beer_found && !$show_api_error) : ?>
     163                <?php if (($is_brewery || $utfb_id !== '') && $beer_found && !$show_api_error) : ?>
    149164                    readonly
    150165                <?php endif; ?>
     
    171186            <?php endif; ?>
    172187        </div>
     188        <div class="embm-metabox__field embm-metabox--utfb">
     189            <?php if (null !== $utfb_data && $utfb_id !== '' && !$show_api_error) : ?>
     190                <p>
     191                    <strong><?php _e('Untappd for Business Menus', 'embm'); ?></strong><br />
     192                    <ul>
     193                        <?php foreach ($menus as $menu): ?>
     194                            <li>
     195                                <a
     196                                    href="<?php echo get_term_link($menu->slug, 'embm_menu'); ?>"
     197                                    title="<?php echo esc_html($menu->name); ?>"
     198                                ><?php echo esc_html($menu->name); ?></a>
     199                            </li>
     200                        <?php endforeach; ?>
     201                    </ul>
     202                </p>
     203            <?php endif; ?>
     204        </div>
    173205    </div>
    174206    <div class="embm-metabox__right">
     
    206238            </div>
    207239        </div>
    208         <div class="embm-metabox--untappd-flush">
    209             <p>
    210                 <strong><?php _e('Refresh Untappd Beer Data', 'embm'); ?></strong>
    211             </p>
    212             <p>
    213                 <a href="#" class="button-secondary" data-api-root="<?php echo $api_root; ?>">
    214                     <?php _e('Flush Cache', 'embm'); ?>
    215                 </a>
    216             </p>
    217             <p class="description">
    218                 <?php _e('This is automatically done daily.', 'embm'); ?>
    219             </p>
     240        <div class="embm-metabox--untappd-actions">
     241            <div class="embm-metabox--untappd-flush">
     242                <p>
     243                    <strong><?php _e('Refresh Untappd Beer Data', 'embm'); ?></strong>
     244                </p>
     245                <p>
     246                    <a href="#" class="button-secondary" data-api-root="<?php echo $api_root; ?>">
     247                        <?php _e('Flush Cache', 'embm'); ?>
     248                    </a>
     249                </p>
     250                <p class="description">
     251                    <?php _e('This is automatically done daily.', 'embm'); ?>
     252                </p>
     253            </div>
     254            <div class="embm-metabox--untappd-sync">
     255                <p>
     256                    <strong><?php _e('Sync Untappd Beer Data', 'embm'); ?></strong>
     257                </p>
     258                <p>
     259                    <a href="#" class="button-secondary" data-api-root="<?php echo $api_root; ?>">
     260                        <?php _e('Sync Data', 'embm'); ?>
     261                    </a>
     262                </p>
     263                <p class="description">
     264                    <span class="warning"><?php _e('WARNING', 'embm'); ?>:</span>
     265                    <?php _e('This will override any changes you have made to this beer.', 'embm'); ?>
     266                </p>
     267            </div>
    220268        </div>
    221269    <?php elseif ($show_api_error && null !== $token) : ?>
     
    294342                $res = EMBM_Admin_Untappd_beer($_POST['embm-untappd-api-root'], $beer_id, $post_id, true);
    295343                if (is_null($res) || is_string($res)) {
    296                     $errors = get_transient($GLOBALS['EMBM_UNTAPPD_CACHE']['save_errors']);
     344                    $errors = get_transient($GLOBALS[EMBM_UNTAPPD_CACHE]['save_errors']);
    297345                    if (is_array($errors) && !array_key_exists('1', $errors)) {
    298346                        array_push($errors, '1');
     
    300348                        $errors = array('1');
    301349                    }
    302                     set_transient($GLOBALS['EMBM_UNTAPPD_CACHE']['save_errors'], $errors, HOUR_IN_SECONDS);
     350                    set_transient($GLOBALS[EMBM_UNTAPPD_CACHE]['save_errors'], $errors, HOUR_IN_SECONDS);
    303351                    return;
    304352                }
  • em-beer-manager/trunk/includes/output/embm-output-filters.php

    r1584318 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    3939
    4040    // Enter the post loop
    41     if (in_the_loop() && (is_singular('embm_beer') || is_tax('embm_style') || is_tax('embm_group'))) {
     41    if (in_the_loop() && (is_singular('embm_beer') || is_tax('embm_style') || is_tax('embm_group') || is_tax('embm_menu'))) {
    4242
    4343        // Set view defaults
     
    145145        if (has_post_thumbnail($post->ID)) {
    146146            $thumb .= '<div class="embm-beer--image">'."\n";
     147            $thumb .= '<a href="'.get_permalink($post->ID).'">'."\n";
    147148            $thumb .= get_the_post_thumbnail($post->ID, 'full')."\n";
     149            $thumb .= '</a>'."\n";
    148150            $thumb .= '</div>'."\n";
    149151        }
     
    187189function EMBM_Output_Filters_classes($classes)
    188190{
    189     if (is_singular('embm_beer') || is_tax('embm_style') || is_tax('embm_group')) {
     191    if (is_singular('embm_beer') || is_tax('embm_style') || is_tax('embm_group') || is_tax('embm_menu')) {
    190192        $classes[] = 'embm-beer';
    191193    }
     
    213215
    214216    // Display beer style
    215     if ($style && (is_singular('embm_beer') || is_tax('embm_group') ) && in_the_loop() && ($title == $post->post_title)) {
     217    if ($style && (is_singular('embm_beer') || is_tax('embm_group') || is_tax('embm_menu')) && in_the_loop() && ($title == $post->post_title)) {
    216218        // Check for the_title() call
    217219        $is_the_title = false;
     
    224226        }
    225227
    226         // Bail if this isn't a the_title() call
    227         if (!$is_the_title) {
     228        // Bail if this isn't a the_title() call or if we've already done this
     229        if (!$is_the_title || did_action('embm_title_filter_applied') !== 0) {
    228230            return $title;
    229231        }
     
    237239        $output .= '</a>)</span>'."\n";
    238240
     241        // Append formatting to title
    239242        $title .= $output;
     243
     244        // Mark action as done
     245        do_action('embm_title_filter_applied');
    240246    }
    241247
  • em-beer-manager/trunk/includes/output/embm-output-shortcodes.php

    r1583981 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    162162                'paginate'          => 'true',
    163163                'orderby'           => '',
    164                 'order'             => ''
     164                'order'             => '',
     165                'meta_key'          => ''
    165166            ),
    166167            $atts,
     
    236237        'sort'      => array(
    237238            'key'       => 'order',
     239            'default'   => '',
     240            'type'      => 'string'
     241        ),
     242        'meta_key'  => array(
     243            'key'       => 'meta_key',
    238244            'default'   => '',
    239245            'type'      => 'string'
     
    268274    $sortby = $beers['sortby'];
    269275    $sort = strtoupper($beers['sort']);
     276    $meta_key = $beers['meta_key'];
    270277
    271278    // Initialize output string
     
    325332    if ($sort != '') {
    326333        $args['order'] = $sort;
     334    }
     335
     336    // Add meta key
     337    if ($meta_key != '') {
     338        $args['meta_key'] = $meta_key;
    327339    }
    328340
  • em-beer-manager/trunk/includes/templates/embm-template-comments.php

    r1583981 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/includes/widgets/embm-widget-list.php

    r1584318 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
  • em-beer-manager/trunk/includes/widgets/embm-widget-untappd.php

    r1584363 r1674966  
    11<?php
    22/**
    3  * Copyright (c) 2013-2016, Erin Morelli.
     3 * Copyright (c) 2013-2017, Erin Morelli.
    44 *
    55 * This program is free software; you can redistribute it and/or
     
    394394    // Include Untappd functions
    395395    if (!function_exists('EMBM_Admin_Untappd_checkins')) {
    396         include_once EMBM_PLUGIN_DIR.'includes/admin/embm-admin-untappd.php';
     396        include_once EMBM_PLUGIN_DIR.'includes/admin/integrations/embm-integrations-untappd.php';
    397397    }
    398398    if (!function_exists('EMBM_Admin_Authorize_token')) {
    399         include_once EMBM_PLUGIN_DIR.'includes/admin/embm-admin-authorize.php';
     399        include_once EMBM_PLUGIN_DIR.'includes/admin/integrations/embm-integrations-authorize.php';
    400400    }
    401401
Note: See TracChangeset for help on using the changeset viewer.