Plugin Directory

Changeset 3080913


Ignore:
Timestamp:
05/03/2024 11:46:54 AM (20 months ago)
Author:
ibenic
Message:

Pushing 8.2.6

Location:
zip-recipes/trunk
Files:
263 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • zip-recipes/trunk/class.ziprecipes.php

    r2832198 r3080913  
    640640        return $all[$index_in_all_array];
    641641    }
     642
     643    public static function get_all_usable_blocks() {
     644        $available_blocks = array_filter( self::all_available_blocks(), function( $item ) {
     645            if ( ! empty( $item['premium'] ) && ! ZipRecipes::is_paying_user() ) {
     646                return false;
     647            }
     648            return true;
     649        } );
     650
     651        $not_data_blocks = array(
     652            'divider',
     653            'nutrition_label'
     654        );
     655
     656        $usable_blocks = [];
     657
     658        foreach ( $available_blocks as $block ) {
     659            if ( in_array( $block['type'], $not_data_blocks, true ) ) {
     660                continue;
     661            }
     662
     663            $usable_blocks[] = $block;
     664        }
     665
     666        return $usable_blocks;
     667    }
     668
     669    public static function is_paying_user() {
     670
     671        $license_valid = false;
     672
     673        if ( defined('ZRDN_PREMIUM') ){
     674            if ( ! class_exists( '\ZRDN\licensing' ) ) {
     675                require_once trailingslashit( ZRDN_PATH ) . 'plugins/Licensing/Licensing.php';
     676            }
     677            $zrdn_license = new licensing();
     678            $license_valid = $zrdn_license->license_is_valid();
     679        }
     680
     681        if ( function_exists( '\ZRDN\zr_fs' ) ) {
     682            $license_valid = zr_fs()->is_paying();
     683        }
     684
     685        if ( $license_valid ) {
     686            return true;
     687        } else {
     688            return false;
     689        }
     690    }
    642691
    643692    /**
  • zip-recipes/trunk/readme.txt

    r2990532 r3080913  
    1 === Recipe Maker For Your Food Blog from Zip Recipes ===
    2 Contributors: RogierLankhorst, markwolters, hgezim,
    3 Plugin Name: Recipe Maker For Your Food Blog from Zip Recipes
     1=== Recipe Cards For Your Food Blog from Zip Recipes ===
     2Contributors: ibenic, freemius
     3Plugin Name: Recipe Cards For Your Food Blog from Zip Recipes (with Gutenberg support)
    44Plugin URI: https://www.ziprecipes.net
    55License: GPLv3 or later
    6 Author URI: https://www.really-simple-plugins.com
    7 Author: Really Simple Plugins
     6Author URI: https://www.wpsimplegiveaways.com
     7Author: Simple Giveaways
    88Donate link: https://www.paypal.me/reallysimplessl
    9 Tags: recipe, recipes, ingredients, food, cooking, blog, SEO
    10 Requires at least: 4.9
    11 Tested up to: 6.4
    12 Stable tag: 8.1.1
     9Tags: recipe, schema.org, seo, food, recipe card, recipe box, print recipe, recipe seo, cooking, nutrition
     10Requires at least: 4.8
     11Tested up to: 6.5.2
     12Stable tag: 8.2.6
    1313Requires PHP: 7.2
    1414
    15 Zip Recipes is the best way to easily create professional-looking recipes fully optimized for Google and your website visitors.
     15Zip Recipes is the best way to easily create a beautiful food blog with professional looking recipes that can be found by Google. AMP (Accelerated Mobile Pages) compatible. Would you like to see what Zip Recipes can do for you? Visit our demo website: [demo.ziprecipes.net!](https://demo.ziprecipes.net/)
    1616
    1717== Description ==
    1818
    19 Get started with the intuitive template editor and create professional recipes for your food blog. With schema.org, Recipe JSON-LD metadata optimized for Google, your recipes will reach more people than before!
    20 
    21 1. Endless possibilities with the template editor and a wide range of settings.
    22 2. Optimize your recipes for Google and other search engines and increase your organic reach.
    23 3. Professional looking recipes for any device.
    24 4. WYSIWYG Editors for adding new recipes of creating your recipe template.
    25 5. Awesome support.
     19Easy to use recipe plugin that adds microdata and schema.org json ld to your recipes, so Google can find and understand them. AMP (Accelerated Mobile Pages) compatible.
     20We help you do that through our 4-step formula:
     21
     221. Easy to use
     232. Professional look
     243. Google friendly (schema.org and AMP compatible, rich snippets)
     254. Integrates seamlessly with ad networks
    2626
    2727Still got questions? [Go to our website for support](https://www.ziprecipes.net/support) or [email us](mailto:[email protected]).
    2828
    29 Zip Recipes is on [GitHub](https://github.com/rlankhorst/zip-recipes-free) as well!
    30 
    31 ## 1. Endless possibilities with the template editor and a wide range of settings.
    32 Zip Recipes is the fastest way to create a recipe. The best way to build a following is to keep your readers coming back for new recipes for them to try. To speed up your workflow and save you time creating recipes, we provide:
    33 
    34 - **WYSIWYG Editors** Adding new recipes of creating your recipe template has never been so easy. [Sneak Preview](https://ziprecipes.net/video-a-quick-introduction-to-the-template-editor/)
    35 - **Easy Copy/Pasting**: You can copy & paste the recipes you already have from Microsoft Word or other programs.
    36 - **Flexible Editor**: Our flexible editor works how you work by allowing you to add recipes to posts, pages or custom post types.
    37 - **Featured Image Support**: You only have to set one image for your post or page if you use featured images. If you don't provide a recipe image, Zip Recipes will add the featured image to Google's rich snippet.
    38 - **No coding required**: We made Zip Recipes easy to use so you don’t need computer knowledge to start publishing your recipes. Even a complete novice can do it!
    39 - **Extensive support** through knowledgebase articles and responsive support.
    40 
    41 https://www.youtube.com/watch?v=-0yMFwgolzQ
    42 
    43 ## 2. More visitors | Rank higher in Google
    44 - **Schema.org and JSON LD**: your recipes will include all the necessary microdata so Google understands them, and will show rich snippets e.g. cooking time and other labels.
    45 - **Mobile friendly**: your recipes will look good on any device.
    46 - **AMP compatible**: out of the box compatible with Google's Accelerated Mobile pages. Zip Recipes will make your recipes load instantly from Google results.
    47 - **Social Media**: Pinterest can also be a huge source of readers for your blog as well. With our JSON-LD recipe markup, your recipes will appear on Pinterest as Rich Recipe Pins. People looking for your type of recipes will discover them and click over to your website giving you an excellent opportunity to build a fan base.
    48 
    49 ## 3. Professional looking recipes
    50 Some readers need a lot of information before even trying to re-create your recipe.
    51 
    52 - **Nutrition information**: Zip Recipes includes nutrition information, cook and prep time, notes and more
    53 - **Rich Snippets**: When users search for recipes, Google will show them the rich snippets with image, rating, nutrition info, cook and preptime, etc.
    54 - **Beautiful print layout**: When clicking the print button, your users will get a beautiful formatted print view.
    55 
    56 ## Love Zip Recipes?
    57 If you enjoy this plugin and you want your site to have the best recipe features, consider purchasing the [premium version](https://ziprecipes.net/premium).
    58 
    59 ## Premium features
    60 * Automatic Nutrition generation
    61 * Automatic serving adjustment for your users
    62 * Choose form several themes
    63 * Reviews and ratings, schema.org integrated
    64 * Recipe search, Recipe index and Recipe Gallery
    65 * Save Recipes on social media, like Big Oven and Yummly
    66 
    67 Check out other plugins developed by Really Simple Plugins as well: [Complianz](https://wordpress.org/plugins/complianz-gdpr/) and [Really Simple SSL](https://wordpress.org/plugins/really-simple-ssl/).
    68 
    69 == Installation ==
    70 
    71 You can get the [detailed installation instructions here](https://ziprecipes.net/knowledge-base/installing/). If you have more questions on how to use the plugin, feel free to reach out to us at [[email protected]](mailto:[email protected]).
    72 
    73 You can download and install the Zip Recipes plugin using the built-in WordPress plugin installer. If you download the Zip Recipes plugin manually, make sure it is uploaded to "/wp-content/plugins/zip-recipes/".
    74 
    75 == Frequently Asked Questions ==
    76 
    77 = Which languages are supported? =
    78 
    79 For all supported languages, please check [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/zip-recipes/)
    80 If you need a new language, you can contribute there!
    81 
    82 = Do you have a premium version? =
    83 
    84 Yes, we do! The premium version has automatically generated nutritional info, ratings, automatic serving adjustment, search by ingredient and easily created recipe galleries. You can learn about our premium features here: [https://www.ziprecipes.net/premium](https://www.ziprecipes.net/)
    85 
    86 = How do I edit a recipe with the Zip Recipes plugin? =
    87 
    88 To edit or create a recipe, click the Zip Recipes icon on the visual editor toolbar, or in Gutenberg, type in "zip", then click the Zip Recipes icon. More info [here](https://ziprecipes.net/knowledge-base/how-to-use-the-zip-recipes-plugin/).
    89 
    90 = Can I use the plugin to add multiple recipes to one post or page? =
    91 
    92 There should only be one recipe per post or page. The plugin does allow for compound recipes which is one way to include multiple lists of ingredients in your post. Under “creating a recipe” in the following article you can read how to do that.  [Click here to learn more](https://ziprecipes.net/knowledge-base/how-to-use-the-zip-recipes-plugin/
    93 
    94 = When I use Zip Recipe plugin where are the recipes stored? =
    95 
    96 Your recipes are always stored on your own website. With Zip Recipes, your recipes are stored safely in a separate database table in your main WordPress database. The recipe table is named wp_amd_zlrecipe_recipes and you can take a look at it yourself using any WordPress database tools at your disposal.
    97 
    98 = How about Intellectual Property? =
    99 
    100 Your recipes are yours only! They're stored on your own server. Zip Recipes is only a tool to show your recipes on the internet.
    101 
    102 = Why do you put a placeholder image into my Edit Post page, instead of my actual recipe? =
    103 
    104 Because of the way WordPress' text editor works, if you decide to add or remove something from your recipe using the text editor, it can very easily mess up the markup of the code - so the Zip Recipe plugin prevents that from happening by not allowing you to edit the recipe in the text editor.
    105 
    106 == Screenshots ==
    107 
    108 1. A Template Editor with Endless Possibilities
    109 2. WYSIWYG Editor when Creating a Recipe
    110 3. Simple Recipe Cards with Nutrition Labels
    111 4. Structured Data Optimized for Google
    112 5. Overview of the most Important Recipe Data
    113 6. Style it to Match your Recipe Articles
    114 7. For more information, please visit [ziprecipes.net](https://ziprecipes.net)
    115 
    11629== Changelog ==
    117 
    118 = 8.1.0 =
     30= 8.2.6 =
     31* New: Nutrition Details Block
     32* Bug fixes
     33
     34= 8.2.5 =
     35* Better integrating with new licensing system
     36* [Premium] Leaving old licensing system for updates in case of the new license not being active
     37* [Premium] Moving back to the older format of the plugin folder name "zip-recipes-lover"
     38
     39= 8.2.4 =
     40* New licensing software
     41
     42= 8.2.3 =
    11943* Security: sanitizing of recipe overview filter
    12044
    121 = 8.1.0 =
     45= 8.2.2 =
    12246* Improvement: PHP 8.2 compatibility
    12347* Fix: Recipe Tags not linking correctly
    12448
    125 = 8.0.9 =
     49= 8.2.1 =
    12650* Improvement: WordPress tested up to 6.3
    12751* Improvement: Fixed deprecation notice
    12852
    129 = 8.0.8 =
    130 * Security: csrf vulnerability
    131 
    132 = 8.0.7 =
     53= 8.2.0 =
     54* Fix: Recipe Grid not working in latest WordPress version
     55
     56= 8.1.9 =
     57* Security: csrf
     58
     59= 8.1.8 =
    13360* Security: xss vulnerability
    13461
    135 = 8.0.6 =
    136 * Improvement: tested up to WP 6.2
    137 
    138 = 8.0.5 =
    139 * Improvement: catch non integer value in nutrition data
    140 
    141 = 8.0.4 =
     62= 8.1.7 =
     63* Tested up to WordPress 6.2
     64
     65= 8.1.6 =
     66* Improvement: catch non integer value in nutrition
     67
     68= 8.1.5 =
    14269* Fix: obsolete hooks
    14370* Fix: PHP 8 compatibility
    14471
    145 = 8.0.3 =
     72= 8.1.4 =
    14673* Fix: creating two recipes when in Classic Editor mode, then clicking first "save", then "save and close"
    14774
    148 = 8.0.2 =
     75= 8.1.3 =
    14976* Fix: obsolete call made it impossible to remove recipe if sharing was enabled before
    15077* Improvement: removed deprecated long_desc attribute from images
    15178
     79= 8.1.2 =
     80* Change: removed recipe sharing option.
     81
     82= 8.1.1 =
     83* Fix: changed names of nutrition API output caused nutrition data not to get saved
     84* Fix: allow disabling of options that are set to default true
     85
     86= 8.1.0 =
     87* Improvement: when recipe did not have a title, the print script should not try to retrieve it.
     88
     89= 8.0.9 =
     90* Improvement: move nutrition label css outside recipe container, so it can be used outside a recipe
     91
     92= 8.0.8 =
     93* Fix: when sharing was not enabled, saving a recipe could cause a validation error
     94
     95= 8.0.7 =
     96* Fix: recipe sharing validation
     97* Improvement: output print file with Recipe title.
     98
     99= 8.0.6 =
     100* Feature: Bulk monetizing
     101* Improvement: Dashboard UI for monetization
     102
     103= 8.0.5 =
     104* Fix: feedback on not understandig ingredients
     105
     106= 8.0.4 =
     107* Improvement: WCAG improvements
     108* Improvement: feedback on active sharing
     109
     110= 8.0.3 =
     111* Fix: smooth scrolling in Chrome could be very slow because of chrome bug
     112* Fix: jump to recipe link not showing in some configurations
     113
     114= 8.0.2 =
     115* Fix: css for new monetize settings block not minified.
     116
    152117= 8.0.1 =
    153 * Bumped tested up to 5.9
    154 
    155 = 8.0.0 =
    156 * New: Grid gallery layout
    157 * several small bug fixes
    158 
    159 = 7.1.6 =
    160 * don't add title to print view if it's not available
    161 
    162 = 7.1.5 =
     118* New: recipe sharing: a new way to monetize your recipes!
     119
     120= 7.1.9 =
    163121* Fix: upgrade causing broken template
    164122* Fix: other plugins injecting notices in Zip settings page
    165123
    166 = 7.1.4 =
     124= 7.1.8 =
    167125* Improvement: template settings min width on smaller screens
    168126* Improvement: Introduction tour on smaller screens not showing correctly
    169127
    170 = 7.1.3 =
     128= 7.1.7 =
     129* Fix: license activation and updating not possible due to name change of plugin
     130
     131= 7.1.6 =
    171132* fix image change in preview mode
    172133* fix stretched image in print view
    173134* fix for shortcode matching with Gutenberg icw elementor
    174135
    175 = 7.1.2 =
     136= 7.1.5 =
     137* Improvement: allow for mixed fraction numbers without spaces
     138
     139= 7.1.4 =
     140* Fix: saving of admin notifications
     141
     142= 7.1.3 =
    176143* Fix: Images in instructions/ingredients were overriden by recipe image, if provided
    177144* Fix: quotes resulted in double quotes on save in notes field
    178145
    179 = 7.1.1 =
     146= 7.1.2 =
    180147* Improvement: prevent overriding nutrition label style by themes
     148* Fix: pattern recognition issue in serving adjustment
    181149* Fix: bold and italic css for Zip Recipes markup
    182150* Fix: make sure demo recipe is installed only once
    183151
    184 = 7.1.0 =
     152= 7.1.1 =
     153* Improvement: catch not existing curl
     154* Improvement: option to add nutrition disclaimer on nutritional text values
    185155* Improvement: template save button also in template editor preview
    186156
    187 = 7.0.6 =
     157= 7.0.13 =
    188158* Fix: default setting for hide print image cause it to show as enabled after disabling it
    189159* Fix: legacy image width setting still listed settings.
    190160
    191 = 7.0.5 =
     161= 7.0.12 =
     162* Fix: for the unit 'g', the regex was not replacing the unit correctly
    192163* Fix: support line breaks in notes and summary
    193164* Improvement: also allow image editing outside preview
    194165
     166= 7.0.11 =
     167* Fix: Custom author option not enabled
     168* Fix: preview image not updating immediately after change
     169
     170= 7.0.10 =
     171* Fix: preview numbering
     172
     173= 7.0.9 =
     174* Fix: pinterest and reddit not sharing correctly
     175
     176= 7.0.8 =
     177* Fix: numbering restarting after image in ingredients/instructions props @yaneli20
     178
     179= 7.0.7 =
     180* Fix: categories check using term_exists instead of is_category
     181
     182= 7.0.6 =
     183* Use title as fallback for description, when summary is empty
     184* Fix: recipe reviews not saving correctly
     185
     186= 7.0.5 =
     187* Removed delay in preview
     188* Changed hyperlinks into divs for ratings/reviews, to prevent bot clickings
     189
    195190= 7.0.4 =
    196 * Fix: preview image not updating immediately after change
     191* Improvement: better preview functionality, making reloading on typing obsolete, and possibly fixing "blocked" messages from security tools
     192* Improvement: improved grid structure with half blocks, which in some themes could cause the blocks not te show next to each other
    197193
    198194= 7.0.3 =
    199 * Fix: pinterest and reddit not sharing correctly
     195* Improvement: show warning when preview is blocked
     196* Fix:inline shortcodes parsing for ingredients and instructions
    200197
    201198= 7.0.2 =
    202 * Fix: numbering restarting after image in ingredients/instructions props @yaneli20
     199* Fix: recipeCategory array not converted to strings
     200* Fix: class in "add recipes" button caused unreadable style in other color schemes.
     201* Fix: migration did not remove image block or recipe title block when these were set to "hide"
    203202
    204203= 7.0.1 =
    205 * Fix: categories check using term_exists instead of is_category
     204* Fix: prevent css override on nobullets css style
     205* Improvement: Rich Snippets video json: add description fallback if no summary provided, and add uploadDate
     206* Fix: instructions list did not contain css for the nobullets class
     207* Fix: Due to 7.0.0.1 version, which compares to 7.0.0 as smaller, upgrade kept running
     208
     209= 7.0.0.1 =
     210* fix: remove log in sanitize function
    206211
    207212= 7.0.0 =
     
    212217* Improved Rich Snippet structure
    213218* Improved customization options
    214 * Drag & Drop recipe template editor
     219* Drag & Drop recipe template
    215220* Added overridable templates
    216221
    217 = 6.4.7 =
    218 * Fix: prevent plugin conflicts with the review notice.
    219 
    220 = 6.4.6 =
    221 * Fix: Jump to recipe link not translatable
    222 * Fix: fallback for rich snippet images if no post or recipe image is found
    223222
    224223= 6.4.5 =
    225 * Fix: in nutrition label, Yield was missing, and serving size on the yield spot
    226 * Fix breaking of links in ingredients when using metric imperial
    227 * Don't show jump to recipes button on non-recipe pages
    228 * Add option to show summary on archive pages
     224* Fix: notifications settings not showing correctly
    229225
    230226= 6.4.4 =
    231 * Added "jump to recipes" feature
    232 * Fix: When Elementor is enabled, but not used, Zip Recipes may not recognize a post as being linked to the recipe
    233 
    234 = 6.4.3 =
    235 * Improvement: added "edit recipe" button to toolbar
    236 
    237 = 6.4.2 =
    238227* Fix: prevent reviews and ratings from being active at the same time
    239228* Improvement: add option to disable notifications for ratings
    240229
     230= 6.4.3 =
     231* Fix: ajax hooks called too late, causing the ajax submissions of ratings not to work.
     232
     233= 6.4.2 =
     234* Fix loading of add ons on certain configurations
     235
    241236= 6.4.0 =
    242 * New settings page style
    243 
    244 = 6.1.7 =
     237* New: notify the administrator when a rating or review is received
     238* Fix: when generating nutrition data, take not saved changes into account
     239* Tweak: new settings page design and technical structure
     240
     241= 6.3.9 =
     242* Tweak: added option to load Grid Recipes with ajax
    245243* Fix: search on recipe overview page
    246244
    247 = 6.1.6 =
     245= 6.3.8 =
     246* Tweak: Recipe Grid could show some spaces on first pageload, because the actual window size was not exactly known yet. By recalculating the grid after 500 ms, this is corrected.
     247
     248= 6.3.7 =
     249* Tweak: Edamam attribution
     250
     251= 6.3.6 =
     252* Tweak: use display_name instead of nicename
     253
     254= 6.3.5 =
     255* Tweak: improved review notice
     256
     257= 6.3.4 =
     258* Fix: WordPress 5.3 compatibility issue with grid2 gutenberg block
     259
     260= 6.3.3 =
     261* Fix: too loose regex causing the metric conversion to recognize words incorrectly as units
     262
     263= 6.3.2 =
     264* Remove cup from imperial metric until there's a more dependable solution
     265
     266= 6.3.1 =
    248267* Added filter to override print CSS url
    249 * Execute shortcodes in recipe
    250 
    251 = 6.1.5 =
     268* Fix: CSS bug because of to generic CSS style
     269
     270= 6.3.0 =
     271* Imperial metric converter
     272
     273= 6.2.6 =
     274* Fix: calculation of serving adjustment not correct when jumping more than one unit at a time (e.g from 2 => 4 servings instead of 2=>3)
     275
     276= 6.2.5 =
     277* Improvement: use default item prop for rating
     278
     279= 6.2.4 =
     280* Improvement: extended rating feature with recipe details
     281
     282= 6.2.3 =
     283* Fix: rating ratingCount checked in json instead of count
     284
     285= 6.2.2 =
    252286* Fix: inverted formate for small snippet image
    253287* Fix: post categories not used
    254288
    255 = 6.1.4 =
     289= 6.2.1 =
    256290* New: Customize the generated rich snippets images
    257291* New: three different rich snippet images with different image ratio's
    258292* Fix: saving and deleting of image not working correctly when the save button is used after the change.
    259293
    260 = 6.1.3 =
     294= 6.2.0 =
     295* New: Recipe Grid new style
     296
     297= 6.1.1 =
    261298* Fix: print styles for default theme
    262299* Improvement: language strings for wp repo
    263300
    264 = 6.1.2 =
    265 * Fix: pre php 7 compatibility
    266 
    267 = 6.1.1 =
    268 * Fix: when no language folder is present, no check on free languages files should be made
    269 
    270301= 6.1.0 =
    271 * improvement: HTML and CSS styled nutrition label
     302* fix: print style did not include nutrition label html and css yet
    272303* language files from the plugin should not get overridden by wp.org translations
    273304* Added option to switch between text and html/css label
     305
     306= 6.0.8 =
     307* fix: notices auto hiding, even when they should not auto hide
     308* Fix: some nutritional data was not being saved
    274309
    275310= 6.0.7 =
     
    280315
    281316= 6.0.6 =
     317* Strip tags from description in JSON output
    282318* Added review notice for free users
    283319* set nutrition info to show by default
    284320* Pull recipe title from post in classic editor popup
     321
     322* added small margin to right of recipe adjustment input box, and put it in CSS class for better customization
    285323
    286324= 6.0.5 =
     
    289327* Added option to clear image
    290328* Use different variable for JSON image, which can fallback to post image
     329* Fixed issue in recipe adjustment caused by move to json for schema.org
    291330
    292331= 6.0.4 =
    293332* Enforce not loading of styles when this option is disabled
    294333* Grab post title as default recipe title
     334* Set yummly share button to smaller width, to prevent whitespace
    295335* Use generic function for shortcode detection to ensure gutenberg compatibility (class.ziprecipes::amp_format)
    296336* Improve schema.org by using only JSON LD, to prevent duplicate recipe detection
     
    312352* User interface redesign
    313353
    314 = 5.0.11 =
    315 * Changed recipe image to large instead of full
    316 * Updated Twig library, fixing some compatibility issues with other twig using plugins, and lowering install size
     354= 5.0.13 =
     355* Updated Twig library
     356* Allow index to show pages as well as posts
    317357* Fix possible time parsing issue when time is entered as 1/2h instead of 0h30m
    318358* Fixes some untranslatable strings
    319359
     360= 5.0.12 =
     361* Changed recipe image to large instead of full
     362* Added option to show nutrition label as schema.org html/css
     363* Added option to show nutrition label with a widget
     364* Added option to hide nutrition label
     365* Added option to hide other nutrition info
     366
     367= 5.0.11 =
     368* limit bootstrap to back-end
     369
    320370= 5.0.10 =
    321 * Fix: roll back of dynamic version detection
     371* Fix: renamed licensing.php file to Licensing.php to fix licensing file not loading on some hosts
    322372
    323373= 5.0.9 =
    324 * Fix: dropped caching twig files
     374* Fix: order of constant declaration could cause plugin conflicts
    325375
    326376= 5.0.8 =
     377* Fix: author did not save when only one author available
     378
     379= 5.0.7 =
     380* Fix: include author in Gutenberg
     381
     382= 5.0.6 =
     383* Fix: URL to print view styles not correct for some themes
    327384* Fix: Gutenberg could cause an error in some situations
    328 * Tweak: Use alt for image when available
    329 
    330 = 5.0.7 =
     385* Fix: compatibility issue with MailPoet
     386* Tweak: use alt text as default for image alt texts
    331387* Tweak: cache directory moved to uploads folder
    332 
    333 = 5.0.6 =
    334 * Tweak: use alt attribute if available in image
    335 * Fix: compatibility issue with MailPoet
    336388* Tweak: Changed cached directory
    337389
  • zip-recipes/trunk/src/block.php

    r2398599 r3080913  
    4848    wp_enqueue_script(
    4949        'zrdn-block', // Handle.
    50         plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
     50        plugins_url( '/build/blocks.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
    5151        array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-api' ), // Dependencies, defined above.
    52         filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: File modification time.
     52        filemtime( plugin_dir_path( __DIR__ ) . 'build/blocks.js' ), // Version: File modification time.
    5353        true // Enqueue the script in the footer.
    5454    );
     
    6262            'zrdn_recipe_preview' => trailingslashit(ZRDN_PLUGIN_URL).  'images/recipe-preview.png',
    6363            'zrdn_grid_preview' => trailingslashit(ZRDN_PLUGIN_URL).  'images/grid-preview.png',
    64 
     64            'active_blocks' => ZipRecipes::get_all_usable_blocks(),
    6565        )
    6666    );
     
    7171    wp_enqueue_style(
    7272        'zrdn-block', // Handle.
    73         trailingslashit(ZRDN_PLUGIN_URL) . "dist/blocks.style.build.css", array( 'wp-edit-blocks' ), ZRDN_VERSION_NUM
     73        trailingslashit(ZRDN_PLUGIN_URL) . "build/blocks.css", array( 'wp-edit-blocks' ), ZRDN_VERSION_NUM
    7474    );
    7575
     
    9696}
    9797
     98function zrdn_render_block_nutrition_label($attributes)
     99{
     100    $html = __('Please select a recipe', 'zip-recipes');
     101    if (isset($attributes['recipe_id']) && absint($attributes['recipe_id'])) {
     102        $html = do_shortcode( '[zrdn-nutrition-label recipe_id=' . absint($attributes['recipe_id']) . ']');
     103    }
     104
     105    return $html;
     106}
     107
     108
    98109register_block_type('zip-recipes/recipe-block', array(
    99110    'render_callback' => __NAMESPACE__ . '\zrdn_render_document_block',
    100111));
    101112
     113register_block_type('zip-recipes/nutrition-label', array(
     114    'attributes' => [
     115        'recipe_id' => [
     116            'type' => 'string',
     117            'default' =>  '',
     118        ]
     119    ],
     120    'render_callback' => __NAMESPACE__ . '\zrdn_render_block_nutrition_label',
     121));
  • zip-recipes/trunk/src/block/editor.scss

    r2278327 r3080913  
    55 * which makes it higher in priority.
    66 */
    7 
     7@import "../common";
  • zip-recipes/trunk/src/block/style.scss

    r2107903 r3080913  
     1@import "../common";
  • zip-recipes/trunk/src/blocks.js

    r2107900 r3080913  
    1111
    1212import './block/block.js';
     13import './nutrition-label/block.js';
  • zip-recipes/trunk/zip-recipes.php

    r2985911 r3080913  
    11<?php
     2
    23/*
    3 Plugin Name: Zip Recipes
    4 Text Domain: zip-recipes
    5 Domain Path: /languages
    6 Plugin URI: http://www.ziprecipes.net/
    7 Plugin GitHub: https://github.com/Really-Simple-Plugins/zip-recipes-free
    8 Description: A plugin that adds all the necessary microdata to your recipes, so they will show up in Google's Recipe Search
    9 Version: 8.1.1
    10 Author: Really Simple Plugins
    11 Author URI: https://www.really-simple-plugins.com/
    12 License: GPL2
    13 Copyright 2022 Really Simple Plugins
    14 This code is derived from the 2.6 version build of ZipList Recipe Plugin released by ZipList Inc.:
    15 http://get.ziplist.com/partner-with-ziplist/wordpress-recipe-plugin/ and licensed under GPL2 or later
     4    Plugin Name: Zip Recipes Lover
     5    Text Domain: zip-recipes
     6    Domain Path: /languages
     7    Plugin URI: https://ziprecipes.net/
     8    Plugin GitHub: https://github.com/really-simple-plugins/zip-recipes-free
     9    Description: A plugin that adds all the necessary microdata to your recipes, so they will show up in Google's Recipe Search
     10    Version: 8.2.6
     11    Author: Igor Benić
     12    Author URI: https://ibenic.com/
     13    License: GPLv3 or later
     14    Copyright 2020 Rogier Lankhorst
    1615*/
    17 
    18 /*  Copyright 2022  Zip Recipes BV  (email : [email protected])
    19     This program is free software; you can redistribute it and/or modify
    20     it under the terms of the GNU General Public License, version 2, as
    21     published by the Free Software Foundation.
    22     This program is distributed in the hope that it will be useful,
     16/*
     17    Zip Recipes is free software: you can redistribute it and/or modify
     18    it under the terms of the GNU General Public License as published by
     19    the Free Software Foundation, either version 3 of the License, or
     20    (at your option) any later version.
     21
     22    Zip Recipes Plugin is distributed in the hope that it will be useful,
    2323    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2424    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2525    GNU General Public License for more details.
     26
    2627    You should have received a copy of the GNU General Public License
    27     along with this program; if not, write to the Free Software
    28     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     28    along with Zip Recipes Plugin. If not, see <http://www.gnu.org/licenses/>.
    2929*/
    30 
    3130namespace ZRDN;
    32 defined('ABSPATH') or die("Error! Cannot be called directly.");
    33 
    34 if (!function_exists(__NAMESPACE__ . '\zrdn_activation_check')) {
    35     /**
    36      * Checks if the plugin can safely be activated, at least php 5.6 and wp 4.6
    37      * @since 7.0.0
    38      */
    39     function zrdn_activation_check()
    40     {
    41         if (version_compare(PHP_VERSION, '7.2', '<')) {
    42             deactivate_plugins(plugin_basename(__FILE__));
    43             wp_die(__('Zip Recipes cannot be activated. The plugin requires PHP 7.2 or higher', 'zip-recipes'));
    44         }
    45 
    46         global $wp_version;
    47         if (version_compare($wp_version, '4.9', '<')) {
    48             deactivate_plugins(plugin_basename(__FILE__));
    49             wp_die(__('Zip Recipes cannot be activated. The plugin requires WordPress 4.9 or higher', 'zip-recipes'));
    50         }
    51     }
    52     register_activation_hook( __FILE__, __NAMESPACE__ . '\zrdn_activation_check' );
    53 }
    54 
    55 if (defined('ZRDN_PLUGIN_BASENAME')) {
    56     if (defined('ZRDN_FREE')) {
    57         deactivate_plugins('zip-recipes/zip-recipes.php');
    58         //add_action('admin_notices', __NAMESPACE__ . '\zrdn_notice_free_active');
    59     }elseif (defined('ZRDN_PRODUCT_ID') && ZRDN_PRODUCT_ID === 1851 ) {
    60         deactivate_plugins('zip-recipes-friend/zip-recipes-friend.php');
    61         //add_action('admin_notices', __NAMESPACE__ . '\zrdn_notice_free_active');
    62     } else {
    63         deactivate_plugins('zip-recipes-lover/zip-recipes-lover.php');
    64     }
     31
     32// Make sure we don't expose any info if called directly
     33defined( 'ABSPATH' ) or die( "Error! Cannot be called directly." );
     34if ( !function_exists( '\\ZRDN\\zr_fs' ) ) {
     35    // Create a helper function for easy SDK access.
     36    function zr_fs() {
     37        global $zr_fs;
     38        if ( !isset( $zr_fs ) ) {
     39            // Include Freemius SDK.
     40            require_once dirname( __FILE__ ) . '/freemius/start.php';
     41            $zr_fs = fs_dynamic_init( array(
     42                'id'             => '14746',
     43                'slug'           => 'zip-recipes',
     44                'premium_slug'   => 'zip-recipes-lover',
     45                'type'           => 'plugin',
     46                'public_key'     => 'pk_8fce9733a1349d1c76abfbef87413',
     47                'is_premium'     => false,
     48                'premium_suffix' => 'Lover',
     49                'has_addons'     => false,
     50                'has_paid_plans' => true,
     51                'menu'           => array(
     52                    'slug'    => 'zrdn-recipes',
     53                    'support' => false,
     54                ),
     55                'is_live'        => true,
     56            ) );
     57        }
     58        return $zr_fs;
     59    }
     60
     61    // Init Freemius.
     62    zr_fs();
     63    function zr_fs_custom_connect_message_on_update(
     64        $message,
     65        $user_first_name,
     66        $plugin_title,
     67        $user_login,
     68        $site_link,
     69        $freemius_link
     70    ) {
     71        return sprintf(
     72            __( 'Hey %1$s' ) . ',<br>' . __( 'Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'zip-recipes' ),
     73            $user_first_name,
     74            '<b>' . $plugin_title . '</b>',
     75            '<b>' . $user_login . '</b>',
     76            $site_link,
     77            $freemius_link
     78        );
     79    }
     80
     81    zr_fs()->add_filter(
     82        'connect_message_on_update',
     83        __NAMESPACE__ . '\\zr_fs_custom_connect_message_on_update',
     84        10,
     85        6
     86    );
     87    $old_edd_license = get_option( 'zrdn_license_key' );
     88    if ( $old_edd_license ) {
     89        zr_fs()->override_i18n( array(
     90            'activate-free-version' => __( "Continue using your old license", 'zip-recipes' ),
     91        ) );
     92    }
     93    // Signal that SDK was initiated.
     94    do_action( 'zr_fs_loaded' );
     95}
     96if ( !function_exists( __NAMESPACE__ . '\\zrdn_activation_check' ) ) {
     97    /**
     98     * Checks if the plugin can safely be activated, at least php 5.6 and wp 4.6
     99     * @since 7.0.0
     100     */
     101    function zrdn_activation_check() {
     102        if ( version_compare( PHP_VERSION, '7.2', '<' ) ) {
     103            deactivate_plugins( plugin_basename( __FILE__ ) );
     104            wp_die( __( 'Zip Recipes cannot be activated. The plugin requires PHP 7.2 or higher', 'zip-recipes' ) );
     105        }
     106        global $wp_version;
     107        if ( version_compare( $wp_version, '4.9', '<' ) ) {
     108            deactivate_plugins( plugin_basename( __FILE__ ) );
     109            wp_die( __( 'Zip Recipes cannot be activated. The plugin requires WordPress 4.9 or higher', 'zip-recipes' ) );
     110        }
     111        if ( file_exists( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'zip-recipes-premium' . DIRECTORY_SEPARATOR . 'zip-recipes-lover.php' ) ) {
     112            deactivate_plugins( 'zip-recipes-premium/zip-recipes-lover.php' );
     113        }
     114    }
     115
     116    register_activation_hook( __FILE__, __NAMESPACE__ . '\\zrdn_activation_check' );
     117}
     118if ( defined( 'ZRDN_PLUGIN_BASENAME' ) ) {
     119    if ( defined( 'ZRDN_FREE' ) ) {
     120        deactivate_plugins( 'zip-recipes/zip-recipes.php' );
     121        //add_action('admin_notices', __NAMESPACE__ . '\zrdn_notice_free_active');
     122    } elseif ( defined( 'ZRDN_PRODUCT_ID' ) && ZRDN_PRODUCT_ID === 1851 ) {
     123        deactivate_plugins( 'zip-recipes-friend/zip-recipes-friend.php' );
     124        //add_action('admin_notices', __NAMESPACE__ . '\zrdn_notice_free_active');
     125    } elseif ( file_exists( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'zip-recipes-premium' . DIRECTORY_SEPARATOR . 'zip-recipes-lover.php' ) ) {
     126        deactivate_plugins( 'zip-recipes-premium/zip-recipes-lover.php' );
     127    } else {
     128        deactivate_plugins( 'zip-recipes-lover/zip-recipes-lover.php' );
     129    }
    65130} else {
    66     define('ZRDN_PATH', plugin_dir_path( __FILE__ ) );
    67     define('ZRDN_FREE', true);
    68     define('ZRDN_PLUGIN_DIRECTORY_URL', plugin_dir_url( __FILE__ ));
    69     define('ZRDN_PLUGIN_BASENAME', plugin_basename(__FILE__));
    70     define('ZRDN_PLUGIN_URL', sprintf('%s/%s/', plugins_url(), dirname(plugin_basename(__FILE__))));
    71     define('ZRDN_API_URL', "https://api.ziprecipes.net");
    72     define('ZRDN_RECIPEDATABASE_URL', 'https://share.ziprecipes.net/');
    73     define('ZRDN_PLUGIN_PRODUCT_NAME', 'Zip Recipes' );
    74     $debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? time() : '';
    75     define('ZRDN_VERSION_NUM', '8.1.1' . $debug);
    76 
    77     add_action('plugins_loaded', __NAMESPACE__ . '\init', 9);
    78 }
    79 
    80 if (!function_exists(__NAMESPACE__ . '\init')) {
    81     function init( $className ) {
    82         require_once( ZRDN_PATH . '/models/Recipe.php' );
    83         require_once( ZRDN_PATH . '_inc/class.ziprecipes.util.php' );
    84         require_once( ZRDN_PATH . 'class.ziprecipes.php' );
    85         require_once( ZRDN_PATH . 'class-review.php' );
    86         require_once( ZRDN_PATH . '_inc/helper_functions.php' );
    87         require_once( ZRDN_PATH . '_inc/PluginBase.php' );
    88         require_once( ZRDN_PATH . 'RecipeTable/RecipeMenu.php' );
    89         require_once( ZRDN_PATH . 'NutritionLabel/NutritionLabel.php' );
    90 
    91         if ( is_admin() ) {
    92             require_once( ZRDN_PATH . 'upgrade-zip.php' );
    93             require_once( ZRDN_PATH . 'grid/grid-enqueue.php' );
    94             require_once( ZRDN_PATH . 'class-field.php' );
    95             require_once( ZRDN_PATH . 'shepherd/tour.php' );
    96 
    97         }
    98         /**
    99          * Recipe sharing
    100          */
    101         require_once( ZRDN_PATH . 'sharing/class-recipe-sharing-admin.php' );
    102 
    103         /**
    104          * API endpoint & Basic Auth
    105          */
    106         require_once( ZRDN_PATH . "controllers/Response.php" );
    107         require_once( ZRDN_PATH . "controllers/EndpointController.php" );
    108         if ( ! function_exists( 'is_plugin_active' ) ) {
    109             require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    110         }
    111         ZipRecipes::init();
    112     }
    113 }
    114 
    115 if (!function_exists(__NAMESPACE__ . '\zrdn_set_defaults')) {
    116     register_activation_hook( __FILE__, __NAMESPACE__ . '\zrdn_set_defaults' );
    117 
    118     /**
    119      * set defaults on activation
    120      */
    121 
    122     function zrdn_set_defaults() {
    123         if (!get_option('zrdn_defaults_set')) {
    124             //set some defaults
    125             $settings = get_option('zrdn_settings_general');
    126             $zrdn_print['show_summary_on_archive_pages'] = true;
    127             update_option('zrdn_settings_general', $settings);
    128 
    129             update_option('zrdn_defaults_set', true);
    130         }
    131     }
    132 }
    133 
    134 if (!function_exists(__NAMESPACE__ . '\zrdn_check_translations')) {
    135     register_activation_hook(__FILE__, __NAMESPACE__ . '\zrdn_check_translations');
    136     function zrdn_check_translations(){
    137         //dirname with levels does not exist before php 7
    138         if (version_compare(PHP_VERSION, '7.0', '<')) return;
    139 
    140         $path = dirname(ZRDN_PATH, 2)."/languages/plugins/";
    141         if (!file_exists($path)) return;
    142 
    143         $extensions = array("po", "mo");
    144         if ($handle = opendir($path)) {
    145             while (false !== ($file = readdir($handle))) {
    146                 if ($file != "." && $file != "..") {
    147                     $file = $path . '/' . $file;
    148                     $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
    149                     if (is_file($file) && in_array($ext, $extensions) && strpos($file, 'zip-recipes')!==FALSE && strpos($file, 'backup')===FALSE) {
    150                         //copy to new file
    151                         $new_name = str_replace('zip-recipes','zip-recipes-backup',$file);
    152 
    153                         rename($file, $new_name);
    154                     }
    155                 }
    156             }
    157             closedir($handle);
    158         }
    159     }
    160 }
    161 
     131    define( 'ZRDN_PLUGIN_PRODUCT_URL', 'https://ziprecipes.net/downloads/zip-recipes-lover' );
     132    define( 'ZRDN_PLUGIN_PRODUCT_FILE', __FILE__ );
     133    define( 'ZRDN_PLUGIN_DIRECTORY_URL', plugin_dir_url( __FILE__ ) );
     134    define( 'ZRDN_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
     135    define( 'ZRDN_PLUGIN_URL', sprintf( '%s/%s/', plugins_url(), dirname( plugin_basename( __FILE__ ) ) ) );
     136    define( 'ZRDN_API_URL', "https://api.ziprecipes.net" );
     137    define( 'ZRDN_PATH', plugin_dir_path( __FILE__ ) );
     138    define( 'ZRDN_PLUGIN_PRODUCT_NAME', 'Zip Recipes Lover' );
     139    $debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : '' );
     140    define( 'ZRDN_VERSION_NUM', '8.2.4' . $debug );
     141    if ( !defined( 'ZRDN_PREMIUM' ) ) {
     142        define( 'ZRDN_FREE', true );
     143    }
     144    add_action( 'plugins_loaded', __NAMESPACE__ . '\\init', 9 );
     145}
     146/**
     147 * --exclude=plugins/AutomaticNutrition*
     148 * --exclude=plugins/Authors*
     149 * --exclude=plugins/CustomTemplates*
     150 * --exclude=plugins/ImperialMetricsConverter*
     151 * --exclude=plugins/Import*
     152 * --exclude=plugins/Licensing*
     153 * --exclude=plugins/MostPopularRecipes*
     154 * --exclude=plugins/RecipeActions*
     155 * --exclude=plugins/RecipeReviews*
     156 * --exclude=plugins/RecipeSearch*
     157 * --exclude=plugins/ServingAdjustment*
     158 * --exclude=plugins/VisitorRating*
     159 * --exclude=plugins/_internal*
     160 * --exclude=*languages/zip-recipes*.po
     161 * --exclude=*languages/zip-recipes*.mo zip-recipes-lover/. zip-recipes/
     162 */
     163if ( !function_exists( __NAMESPACE__ . '\\init' ) ) {
     164    function init(  $className  ) {
     165        require_once ZRDN_PATH . '/models/Recipe.php';
     166        require_once ZRDN_PATH . '_inc/class.ziprecipes.util.php';
     167        require_once ZRDN_PATH . 'class.ziprecipes.php';
     168        require_once ZRDN_PATH . 'class-review.php';
     169        require_once ZRDN_PATH . '_inc/helper_functions.php';
     170        require_once ZRDN_PATH . '_inc/PluginBase.php';
     171        require_once ZRDN_PATH . 'RecipeTable/RecipeMenu.php';
     172        require_once ZRDN_PATH . 'NutritionLabel/NutritionLabel.php';
     173        require_once ZRDN_PATH . 'cron/cron.php';
     174        if ( is_admin() ) {
     175            require_once ZRDN_PATH . 'upgrade-zip.php';
     176            require_once ZRDN_PATH . 'grid/grid-enqueue.php';
     177            require_once ZRDN_PATH . 'class-field.php';
     178            require_once ZRDN_PATH . 'shepherd/tour.php';
     179        }
     180        /**
     181         * API endpoint & Basic Auth
     182         */
     183        require_once ZRDN_PATH . "controllers/Response.php";
     184        require_once ZRDN_PATH . "controllers/EndpointController.php";
     185        if ( !function_exists( 'is_plugin_active' ) ) {
     186            require_once ABSPATH . '/wp-admin/includes/plugin.php';
     187        }
     188        ZipRecipes::init();
     189    }
     190
     191}
     192if ( !function_exists( __NAMESPACE__ . '\\zrdn_set_defaults' ) ) {
     193    register_activation_hook( __FILE__, __NAMESPACE__ . '\\zrdn_set_defaults' );
     194    /**
     195     * set defaults on activation
     196     */
     197    function zrdn_set_defaults() {
     198        if ( !get_option( 'zrdn_defaults_set' ) ) {
     199            //set some defaults
     200            $settings = get_option( 'zrdn_settings_general' );
     201            $zrdn_print['show_summary_on_archive_pages'] = true;
     202            update_option( 'zrdn_settings_general', $settings );
     203            update_option( 'zrdn_defaults_set', true );
     204        }
     205    }
     206
     207}
     208if ( !function_exists( __NAMESPACE__ . '\\zrdn_check_translations' ) ) {
     209    register_activation_hook( __FILE__, __NAMESPACE__ . '\\zrdn_check_translations' );
     210    function zrdn_check_translations() {
     211        //dirname with levels does not exist before php 7
     212        if ( version_compare( PHP_VERSION, '7.0', '<' ) ) {
     213            return;
     214        }
     215        $path = dirname( ZRDN_PATH, 2 ) . "/languages/plugins/";
     216        if ( !file_exists( $path ) ) {
     217            return;
     218        }
     219        $extensions = array("po", "mo");
     220        if ( $handle = opendir( $path ) ) {
     221            while ( false !== ($file = readdir( $handle )) ) {
     222                if ( $file != "." && $file != ".." ) {
     223                    $file = $path . '/' . $file;
     224                    $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
     225                    if ( is_file( $file ) && in_array( $ext, $extensions ) && strpos( $file, 'zip-recipes' ) !== FALSE && strpos( $file, 'backup' ) === FALSE ) {
     226                        //copy to new file
     227                        $new_name = str_replace( 'zip-recipes', 'zip-recipes-backup', $file );
     228                        rename( $file, $new_name );
     229                    }
     230                }
     231            }
     232            closedir( $handle );
     233        }
     234    }
     235
     236}
    162237/**
    163238 * Load iframe has to hook into admin init, otherwise languages are not loaded yet.
    164239 *
    165240 * */
    166 if (!function_exists(__NAMESPACE__ . '\zrdn_maybe_load_iframe')) {
    167     function zrdn_maybe_load_iframe()
    168     {
    169         // Setup query catch for recipe insertion popup.
    170         if (strpos($_SERVER['REQUEST_URI'], 'media-upload.php') && strpos($_SERVER['REQUEST_URI'], '&type=z_recipe') && !strpos($_SERVER['REQUEST_URI'], '&wrt=')) {
    171             // pluggable.php is needed for current_user_can
    172             require_once(ABSPATH . 'wp-includes/pluggable.php');
    173 
    174             // user is logged in and can edit posts or pages
    175             if (\current_user_can('edit_posts') || \current_user_can('edit_pages')) {
    176                 $get_info = $_REQUEST;
    177                 $post_id = isset($get_info["post_id"]) ? intval($get_info["post_id"]) : 0;
    178 
    179                 if (isset($get_info["recipe_post_id"]) &&
    180                     !isset($get_info["add-recipe-button"]) &&
    181                     strpos($get_info["recipe_post_id"], '-') !== false
    182                 ) { // EDIT recipe
    183                     $recipe_id = preg_replace('/[0-9]*?\-/i', '', $get_info["recipe_post_id"]);
    184                     wp_redirect(add_query_arg(array("page"=>"zrdn-recipes","action"=>"new","id"=>$recipe_id, "post_id" => $post_id,"popup"=>true),admin_url("admin.php")));
    185 
    186                 } else { // New recipe
    187                     wp_redirect(add_query_arg(array("page"=>"zrdn-recipes","action"=>"new", "post_id" => $post_id,"popup"=>true),admin_url("admin.php")));
    188                 }
    189             }
    190             exit;
    191         }
    192     }
    193     add_action('admin_init', __NAMESPACE__ . '\zrdn_maybe_load_iframe', 30);
    194 }
    195 
    196 if ( ! function_exists( __NAMESPACE__ . '\zrdn_start_tour' ) ) {
    197     /**
    198      * Start the tour of the plugin on activation
    199      */
    200     function zrdn_start_tour() {
    201         if ( ! get_site_option( 'zrdn_tour_shown_once' ) ) {
    202             update_site_option( 'zrdn_tour_started', true );
    203         }
    204     }
    205 
    206     register_activation_hook( __FILE__, __NAMESPACE__ . '\zrdn_start_tour' );
    207 }
     241if ( !function_exists( __NAMESPACE__ . '\\zrdn_maybe_load_iframe' ) ) {
     242    function zrdn_maybe_load_iframe() {
     243        // Setup query catch for recipe insertion popup.
     244        if ( strpos( $_SERVER['REQUEST_URI'], 'media-upload.php' ) && strpos( $_SERVER['REQUEST_URI'], '&type=z_recipe' ) && !strpos( $_SERVER['REQUEST_URI'], '&wrt=' ) ) {
     245            // pluggable.php is needed for current_user_can
     246            require_once ABSPATH . 'wp-includes/pluggable.php';
     247            // user is logged in and can edit posts or pages
     248            if ( \current_user_can( 'edit_posts' ) || \current_user_can( 'edit_pages' ) ) {
     249                $get_info = $_REQUEST;
     250                $post_id = ( isset( $get_info["post_id"] ) ? intval( $get_info["post_id"] ) : 0 );
     251                if ( isset( $get_info["recipe_post_id"] ) && !isset( $get_info["add-recipe-button"] ) && strpos( $get_info["recipe_post_id"], '-' ) !== false ) {
     252                    // EDIT recipe
     253                    $recipe_id = preg_replace( '/[0-9]*?\\-/i', '', $get_info["recipe_post_id"] );
     254                    wp_redirect( add_query_arg( array(
     255                        "page"    => "zrdn-recipes",
     256                        "action"  => "new",
     257                        "id"      => $recipe_id,
     258                        "post_id" => $post_id,
     259                        "popup"   => true,
     260                    ), admin_url( "admin.php" ) ) );
     261                } else {
     262                    // New recipe
     263                    wp_redirect( add_query_arg( array(
     264                        "page"    => "zrdn-recipes",
     265                        "action"  => "new",
     266                        "post_id" => $post_id,
     267                        "popup"   => true,
     268                    ), admin_url( "admin.php" ) ) );
     269                }
     270            }
     271            exit;
     272        }
     273    }
     274
     275    add_action( 'admin_init', __NAMESPACE__ . '\\zrdn_maybe_load_iframe', 30 );
     276}
     277if ( !function_exists( __NAMESPACE__ . '\\zrdn_start_tour' ) ) {
     278    /**
     279     * Start the tour of the plugin on activation
     280     */
     281    function zrdn_start_tour() {
     282        if ( !get_site_option( 'zrdn_tour_shown_once' ) ) {
     283            update_site_option( 'zrdn_tour_started', true );
     284        }
     285    }
     286
     287    register_activation_hook( __FILE__, __NAMESPACE__ . '\\zrdn_start_tour' );
     288}
Note: See TracChangeset for help on using the changeset viewer.