Skip to content

Commit

Permalink
Merge pull request #91 from XjSv/develop
Browse files Browse the repository at this point in the history
Release v1.9.5
  • Loading branch information
XjSv authored Jan 7, 2025
2 parents 3a12d23 + 9afc183 commit bed1a31
Show file tree
Hide file tree
Showing 16 changed files with 440 additions and 386 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors:
given-names: Justin
- family-names: Tresova
given-names: Armand
version: 1.9.4
version: 1.9.5
doi: 10.5281/zenodo.1171250
date-released: 2017-05-08
url: "https://github.com/XjSv/cooked"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"recipe"
],
"homepage": "https://wordpress.org/plugins/cooked/",
"version": "1.9.4",
"version": "1.9.5",
"type": "wordpress-plugin",
"license": "GPL-3.0-or-later",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cooked.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Description: A recipe plugin for WordPress.
Author: Gora Tech
Author URI: https://goratech.dev
Version: 1.9.4
Version: 1.9.5
Text Domain: cooked
Domain Path: languages
License: GPL2
Expand All @@ -30,7 +30,7 @@

require_once __DIR__ . '/vendor/autoload.php';

define( 'COOKED_VERSION', '1.9.4' );
define( 'COOKED_VERSION', '1.9.5' );
define( 'COOKED_DEV', false );

if ( ! class_exists( 'Cooked_Plugin' ) ) :
Expand Down
2 changes: 1 addition & 1 deletion includes/class.cooked-admin-enqueues.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function admin_enqueues( $hook ) {
if ($enqueue):

$old_recipes = get_transient( 'cooked_classic_recipes' );
if ( $old_recipes != 'complete' ):
if ( $old_recipes && $old_recipes !== 'complete' && is_array($old_recipes) ):
$total_old_recipes = count( $old_recipes );
else:
$total_old_recipes = 0;
Expand Down
21 changes: 20 additions & 1 deletion includes/class.cooked-admin-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function __construct() {
if (!is_admin()) {
add_action( 'admin_bar_menu', [&$this, 'add_admin_bar_menu'], 100 );
}

add_action('parent_file', [&$this, 'parent_file_filter']);
}

public function add_menu() {
Expand All @@ -36,7 +38,7 @@ public function add_menu() {

if ( isset($cooked_taxonomies_for_menu) && !empty($cooked_taxonomies_for_menu) ) {
foreach ( $cooked_taxonomies_for_menu as $menu_item ) {
add_submenu_page( $menu_item['menu'], $menu_item['name'], $menu_item['name'], $menu_item['capability'], $menu_item['url'], '' );
add_submenu_page($menu_item['menu'], $menu_item['name'], $menu_item['name'], $menu_item['capability'], $menu_item['url'], '', null );
}
}

Expand Down Expand Up @@ -65,6 +67,23 @@ public function add_admin_bar_menu() {
}
}

public function parent_file_filter($parent_file) {
global $submenu_file, $current_screen, $pagenow;
$post_type = 'cp_recipe';

if ($current_screen->post_type === $post_type && $pagenow === 'edit-tags.php') {
$_cooked_taxonomies = Cooked_Taxonomies::get();

if (array_key_exists($current_screen->taxonomy, $_cooked_taxonomies)) {
$submenu_file = 'edit-tags.php?taxonomy=' . $current_screen->taxonomy . '&post_type=' . $post_type;
}

$parent_file = 'cooked_recipes_menu';
}

return $parent_file;
}

// Settings Panel
public function cooked_settings_page() {
if (!current_user_can('edit_cooked_settings')) {
Expand Down
16 changes: 15 additions & 1 deletion includes/class.cooked-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function __construct() {
add_action( 'init', [&$this, 'init'] );
add_filter( 'admin_init', [&$this, 'init_roles'] );
add_action( 'after_setup_theme', [&$this, 'image_sizes'] );
//add_action( 'template_redirect', array( &$this, 'redirects' ) );
// add_action( 'template_redirect', [&$this, 'redirects'] );
add_action( 'wp_head', [&$this, 'cooked_meta_tags'], 5 );
add_action( 'manage_cp_recipe_posts_custom_column', [&$this, 'custom_columns_data'], 10, 2 );

Expand Down Expand Up @@ -361,13 +361,27 @@ public static function init() {
}
}

// Search sort pagination
add_rewrite_rule(
'^' . $base_path . 'search/([^/]*)/sort/([^/]*)/page/([^/]*)/?',
'index.php?page_id=' . $_cooked_settings['browse_page'] . '&cooked_search_s=$matches[1]&cooked_browse_sort_by=$matches[2]&paged=$matches[3]',
'top'
);

// Search sort
add_rewrite_rule(
'^' . $base_path . 'search/([^/]*)/sort/([^/]*)/?',
'index.php?page_id=' . $_cooked_settings['browse_page'] . '&cooked_search_s=$matches[1]&cooked_browse_sort_by=$matches[2]',
'top'
);

// Sort Pagination
add_rewrite_rule(
'^' . $base_path . 'sort/([^/]*)/page/([^/]*)/?',
'index.php?page_id=' . $_cooked_settings['browse_page'] . '&cooked_browse_sort_by=$matches[1]&paged=$matches[2]',
'top'
);

// Sort
add_rewrite_rule(
'^' . $base_path . 'sort/([^/]*)/?',
Expand Down
6 changes: 5 additions & 1 deletion includes/class.cooked-recipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct() {
add_filter('get_canonical_url', [&$this, 'modify_browse_page_canonical_url'], 20, 2);
}

public static function get( $args = false, $single = false, $ids_only = false ) {
public static function get( $args = false, $single = false, $ids_only = false, $limit = false ) {
$recipes = [];
$counter = 0;

Expand Down Expand Up @@ -62,6 +62,10 @@ public static function get( $args = false, $single = false, $ids_only = false )
$args['fields'] = 'ids';
endif;

if ( $limit ):
$args['limit'] = $limit;
endif;

// Search Query
elseif ( $args && isset($args['s']) && isset($args['meta_query']) ):

Expand Down
6 changes: 3 additions & 3 deletions includes/class.cooked-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

class Cooked_SEO {

public static function json_ld( $recipe = false ){

public static function json_ld( $recipe = false ) {
global $_cooked_settings;
if ( !in_array( 'disable_schema_output', $_cooked_settings['advanced'] ) ):

if ( !empty($_cooked_settings['advanced']) && !in_array( 'disable_schema_output', $_cooked_settings['advanced'] ) ):

$schema_values_json = wp_json_encode( self::schema_values( $recipe ) );

Expand Down
1 change: 1 addition & 0 deletions includes/class.cooked-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ private static function needs_rewrite_flush( $old_version ) {
'1.9.1', // Hotfix for the permalink structure.
'1.9.2', // Hotfix for the permalink structure.
'1.9.4', // Hotfix for the permalink structure.
'1.9.5', // Hotfix for the permalink structure (sort & search).
];

// If old version is newer than our latest flush requirement, no flush needed
Expand Down
18 changes: 14 additions & 4 deletions includes/class.cooked-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ function __construct() {
}

public function preprocess_shortcode($output, $tag, $attr, $m) {
// Tags to skip
$skip_tags = [
'cooked-search',
'cooked-browse',
'cooked-timer',
'cooked-recipe',
'cooked-recipe-list',
'cooked-recipe-card',
];

// Only process for Cooked shortcodes
if (strpos($tag, 'cooked-') === false) {
if (is_front_page() || strpos($tag, 'cooked-') === false || in_array($tag, $skip_tags)) {
return $output;
}

Expand All @@ -66,12 +76,12 @@ public function preprocess_shortcode($output, $tag, $attr, $m) {
if (empty($recipe_settings)) {
// Try to get recipe settings from current post.
$post_id = isset($post->ID) ? $post->ID : false;
if ($post_id && get_post_type( $post_id ) === 'cp_recipe' ) {
if ($post_id && get_post_type( $post_id ) === 'cp_recipe') {
$recipe_settings = Cooked_Recipes::get($post_id, true);
} else {
// We are in the editor but not on a recipe post type. Maybe a single recipe template?
// Uses the first recipe found in the database as a sample.
$recipe_settings = Cooked_Recipes::get( false, true );
$recipe_settings = Cooked_Recipes::get(false, true, false, 1);
}

// If still empty and we have a specific recipe ID in attributes, try to get them.
Expand Down Expand Up @@ -273,7 +283,7 @@ public function cooked_recipe_shortcode( $atts, $content = null ) {
'id' => false,
], $atts);

global $recipe_settings,$_cooked_content_unfiltered;
global $recipe_settings, $_cooked_content_unfiltered;

ob_start();

Expand Down
Loading

0 comments on commit bed1a31

Please sign in to comment.