Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: composer install --no-dev --optimize-autoloader --no-interaction --prefer-dist --no-progress

- name: Create plugin zip
run: bunx bestzip build/cooked.zip cooked.php LICENSE readme.txt wpml-config.xml assets/ includes/ languages/ templates/ vendor/
run: bunx bestzip build/cooked.zip cooked.php LICENSE readme.txt wpml-config.xml assets/ includes/ languages/ sample-data/ templates/ vendor/

- name: Create Release
uses: softprops/action-gh-release@v2
Expand Down
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"themes": ["WordPress/twentytwentyfive"],
"plugins": ["."],
"port": 8888,
"testsPort": 8889,
"testsEnvironment": false,
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
Expand Down
35 changes: 35 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,41 @@ button.cooked-button {
margin-left: 1rem;
}

/* Measurement System Switcher */
.cooked-recipe-info span.cooked-measurement-system {
padding-left: 3rem;
}
.cooked-recipe-info span.cooked-measurement-system select.cooked-measurement-system-changer {
opacity: 0;
position: absolute;
bottom: 0;
left: 0;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
border: none;
background: none;
width: 100%;
padding: 0;
margin: 0;
}
.cooked-recipe-info span.cooked-measurement-system-icon {
opacity: 0.5;
width: 1rem;
height: 1rem;
font-size: 2.2rem;
line-height: 1;
display: block;
position: absolute;
top: 50%;
left: 0;
margin: -1.1rem 0 0 0;
}
.cooked-recipe-info span.cooked-measurement-system-icon i.cooked-icon {
display: block;
}

/* Recipe Image */
.cooked-post-featured-image {
max-width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/style.min.css

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion assets/js/cooked-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,24 @@ var cooked_loading = false;
});
}

/**** 5. Browse Search Button ****/
/**** 4b. Measurement System Switcher ****/

if ( $('.cooked-measurement-system').length ) {
var msSelectField = $('.cooked-measurement-system').find('select');
msSelectField.on('change', function(e) {
e.preventDefault();
var ms = $(this).children("option:selected").val();
const url = new URL(window.location.href);
if ( ms ) {
url.searchParams.set('measurement_system', ms);
} else {
url.searchParams.delete('measurement_system');
}
window.location.href = url.toString();
});
}

/**** 5. Browse Search Button ****/

if ( $_Cooked_Recipe_Search.length ) {
$('body').on( 'click',function(e) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/cooked-functions.min.js

Large diffs are not rendered by default.

58 changes: 14 additions & 44 deletions bun.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"prefer-stable": true,
"require": {
"php": ">=7.4.0",
"nxp/math-executor": "^2.3"
"nxp/math-executor": "^2.3",
"php-units-of-measure/php-units-of-measure": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
Expand Down
55 changes: 54 additions & 1 deletion composer.lock

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

1 change: 1 addition & 0 deletions cooked.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ private function includes() {
require_once COOKED_DIR . 'includes/class.cooked-recipe-meta.php';
require_once COOKED_DIR . 'includes/class.cooked-shortcodes.php';
require_once COOKED_DIR . 'includes/class.cooked-measurements.php';
require_once COOKED_DIR . 'includes/class.cooked-unit-converter.php';
require_once COOKED_DIR . 'includes/class.cooked-admin-enqueues.php';
require_once COOKED_DIR . 'includes/class.cooked-enqueues.php';
require_once COOKED_DIR . 'includes/class.cooked-admin-menus.php';
Expand Down
113 changes: 58 additions & 55 deletions includes/class.cooked-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,82 @@
* @since 1.13.0
*/

/**
* Exit if accessed directly
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit;
}

if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
return;
return;
}

/**
* Run Cooked maintenance and migration tools.
*/
class Cooked_CLI_Tools_Command {

/**
* Run a Cooked migration/maintenance tool by name.
*
* ## OPTIONS
*
* <tool>
* : The tool to run. Use `wp cooked tools list` to see available tools.
*
* ## EXAMPLES
*
* wp cooked tools run remove_recipes_from_cooked_user_meta
* wp cooked tools run update_rewrite_rules
*
* @param array $args Positional args. 0 = tool name.
* @param array $assoc_args Associative args.
*/
public function run( $args, $assoc_args ) {
if ( empty( $args[0] ) ) {
\WP_CLI::error( __( 'Please provide a tool name. Use `wp cooked tools list` to see available tools.', 'cooked' ) );
}
/**
* Run a Cooked migration/maintenance tool by name.
*
* ## OPTIONS
*
* <tool>
* : The tool to run. Use `wp cooked tools list` to see available tools.
*
* ## EXAMPLES
*
* wp cooked tools run remove_recipes_from_cooked_user_meta
* wp cooked tools run update_rewrite_rules
*
* @param array $args Positional args. 0 = tool name.
* @param array $assoc_args Associative args.
*/
public function run( $args, $assoc_args ) {
if ( empty( $args[0] ) ) {
\WP_CLI::error( __( 'Please provide a tool name. Use `wp cooked tools list` to see available tools.', 'cooked' ) );
}

$tool_name = $args[0];
$result = Cooked_Updates::run_tool( $tool_name );
$tool_name = $args[0];
$result = Cooked_Updates::run_tool( $tool_name );

if ( is_wp_error( $result ) ) {
\WP_CLI::error( $result->get_error_message() );
}
if ( is_wp_error( $result ) ) {
\WP_CLI::error( $result->get_error_message() );
}

\WP_CLI::success( __( 'Tool completed successfully.', 'cooked' ) );
}
\WP_CLI::success( __( 'Tool completed successfully.', 'cooked' ) );
}

/**
* List available Cooked tools that can be run on demand.
*
* ## EXAMPLES
*
* wp cooked tools list
*
* @param array $args Positional args.
* @param array $assoc_args Associative args.
*/
public function list_tools( $args, $assoc_args ) {
$tools = Cooked_Updates::get_runnable_tools();
/**
* List available Cooked tools that can be run on demand.
*
* ## EXAMPLES
*
* wp cooked tools list
*
* @param array $args Positional args.
* @param array $assoc_args Associative args.
*/
public function list_tools( $args, $assoc_args ) {
$tools = Cooked_Updates::get_runnable_tools();

if ( empty( $tools ) ) {
\WP_CLI::log( __( 'No tools available.', 'cooked' ) );
return;
}
if ( empty( $tools ) ) {
\WP_CLI::log( __( 'No tools available.', 'cooked' ) );
return;
}

$rows = [];
foreach ( $tools as $tool ) {
$rows[] = [
'id' => $tool['id'],
'name' => $tool['name'],
'description' => $tool['description'],
];
}
$rows = array();
foreach ( $tools as $tool ) {
$rows[] = array(
'id' => $tool['id'],
'name' => $tool['name'],
'description' => $tool['description'],
);
}

\WP_CLI\Utils\format_items( 'table', $rows, [ 'id', 'name', 'description' ] );
}
\WP_CLI\Utils\format_items( 'table', $rows, array( 'id', 'name', 'description' ) );
}
}

\WP_CLI::add_command( 'cooked tools', 'Cooked_CLI_Tools_Command' );
4 changes: 4 additions & 0 deletions includes/class.cooked-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ public static function field_message( $name, $field_options, $color, $field ) {
}

public static function field_csv_upload( $name, $field_options, $color, $field ) {
echo '<p class="cooked-import-note"><strong>' . __( 'Download sample CSV files:', 'cooked' ) . '</strong> ';
echo '<a href="' . esc_url( COOKED_URL . 'sample-data/recipes-small.csv' ) . '" download>' . __( 'Small (1 recipe)', 'cooked' ) . '</a>, ';
echo '<a href="' . esc_url( COOKED_URL . 'sample-data/recipes-medium.csv' ) . '" download>' . __( 'Medium (3 recipes)', 'cooked' ) . '</a>, ';
echo '<a href="' . esc_url( COOKED_URL . 'sample-data/recipes-large.csv' ) . '" download>' . __( 'Large (10 recipes)', 'cooked' ) . '</a></p>';
echo '<form id="cooked-csv-import-form" enctype="multipart/form-data">';
echo '<p>';
echo '<input type="file" id="cooked-csv-file" name="csv_file" accept=".csv" required>';
Expand Down
Loading