Skip to content

Commit

Permalink
Added Discord Link to Welcome Page
Browse files Browse the repository at this point in the history
Also tooltipster theme updates.
  • Loading branch information
XjSv committed Aug 15, 2024
1 parent 4c41e3e commit 0d24df1
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
34 changes: 20 additions & 14 deletions assets/admin/js/cooked-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var $_CookedConditionalTimeout = false;
// Save as Default
if ($_CookedRecipeSaveDefault.length) {
var saveDefaultTooltip = $_CookedRecipeSaveDefault.tooltipster({
theme : 'tooltipster-light',
theme : ['tooltipster-light', 'tooltipster-sideTip-cooked'],
trigger : 'click',
animation : 'grow',
delay : 0,
Expand Down Expand Up @@ -92,7 +92,7 @@ var $_CookedConditionalTimeout = false;
total_recipes = Object.keys(recipe_ids).length;

if (total_recipes > 0) {
cooked_set_default_template(json_recipe_ids, total_recipes, recipe_editor_content, cooked_save_default_bulk_nonce);
cooked_set_default_template(json_recipe_ids, total_recipes, recipe_editor_content, cooked_save_default_bulk_nonce, instance);
}
}
}
Expand Down Expand Up @@ -137,8 +137,9 @@ var $_CookedConditionalTimeout = false;
}
});

$('.cooked-layout-load-default').on('click',function(e) {
$('.cooked-layout-load-default').on('click', function(e) {
e.preventDefault();

var thisButton = $(this),
thisContainer = thisButton.parent(),
confirm_load = confirm( cooked_js_vars.i18n_confirm_load_default ),
Expand All @@ -149,7 +150,9 @@ var $_CookedConditionalTimeout = false;
thisContainer.find('.button, .button-primary').addClass('disabled');
var ajax__save_default_all = $.post(
cooked_js_vars.ajax_url,
{ action:'cooked_load_default' },
{
action: 'cooked_load_default'
},
function (result) {
if ( recipe_editor === null ) {
recipe_editor_textarea.val( result );
Expand All @@ -171,16 +174,16 @@ var $_CookedConditionalTimeout = false;
}

// Cooked Select Wrappers
if ($_CookedSelectFields.length){
$_CookedSelectFields.each(function(){
$(this).wrap('<div class="cooked-select-wrapper" />');
if ($_CookedSelectFields.length) {
$_CookedSelectFields.each(function() {
$(this).wrap('<div class="cooked-select-wrapper" />');
});
}

// Cooked Tooltips
if ($_CookedTooltips.length){
$_CookedTooltips.tooltipster({
theme : 'tooltipster-light',
theme : ['tooltipster-light', 'tooltipster-sideTip-cooked'],
animation : 'grow',
delay : 100,
speed : 200,
Expand All @@ -191,16 +194,16 @@ var $_CookedConditionalTimeout = false;
}

// Cooked Shortcode Fields
if ($_CookedShortcodeField.length){
$_CookedShortcodeField.on('click',function(e){
if ($_CookedShortcodeField.length) {
$_CookedShortcodeField.on('click',function(e) {
$(this).select();
});
}

// Conditional Fields (Recipes and Settings Pages)
if ($_CookedConditionals.length){
if ($_CookedConditionals.length) {
var conditionalFields = [];
$_CookedConditionals.each(function(){
$_CookedConditionals.each(function() {
var thisBlock = $(this),
thisBlockType,
thisID = $(this).data('condition'),
Expand Down Expand Up @@ -650,7 +653,7 @@ var $_CookedConditionalTimeout = false;

var cooked_recipe_update_counter = 0;

function cooked_set_default_template(recipe_ids, total_recipes, content, nonce) {
function cooked_set_default_template(recipe_ids, total_recipes, content, nonce, instance) {
var temp_counter = 0,
total_counter = 0,
progress_percent = 0;
Expand All @@ -664,6 +667,7 @@ function cooked_set_default_template(recipe_ids, total_recipes, content, nonce)
progress.addClass('cooked-active');
progress_text.addClass('cooked-active');
progress_bar.css({ "width" : "0%" });
instance.reposition();
}

var ajax__bulk_save_default_template = jQuery.post(
Expand All @@ -684,12 +688,14 @@ function cooked_set_default_template(recipe_ids, total_recipes, content, nonce)
progress_percent = Math.round((cooked_recipe_update_counter / total_recipes ) * 100);
progress_bar.css({ "width" : progress_percent + "%" });
progress_text.text(cooked_recipe_update_counter + " / " + total_recipes);
cooked_set_default_template(new_recipe_ids, total_recipes, content, nonce);
cooked_set_default_template(new_recipe_ids, total_recipes, content, nonce, instance);
} else {
jQuery('.cooked-save-default-all').text(cooked_js_vars.i18n_applied);
progress_bar.css({ "width" : "100%" });
progress.removeClass('cooked-active');
progress_text.removeClass('cooked-active').text("");

instance.reposition();
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion assets/admin/js/cooked-functions.min.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion cooked.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public static function instance() {
self::$instance->widget = new Cooked_Widgets();
self::$instance->gutenberg = new Cooked_Gutenberg();
self::$instance->elementor = new Cooked_Elementor();
//self::$instance->delicious_recipes = new Delicious_Recipes();

self::$instance->module_setup();
}
Expand Down Expand Up @@ -453,6 +452,15 @@ function Cooked() {
// Let's get cooking!
$CookedPlugin = Cooked();

/**
* Plugin Action Links Filter
*
* Adds a "Upgrade to Pro" link to the plugin list page.
*
* @since 1.0.0
* @param array $links
* @return array
*/
add_filter('plugin_action_links_' . plugin_basename(__FILE__), function($links) {
if (!class_exists( 'Cooked_Pro_Plugin')) {
return array_merge(['<a href="https://cooked.pro/get-cooked/" target="_blank">Upgrade to Pro</a>'], $links);
Expand Down
8 changes: 3 additions & 5 deletions includes/class.cooked-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
class Cooked_Gutenberg {

public function __construct(){
add_filter( 'use_block_editor_for_post_type', array( &$this, 'gutenberg_support' ), 10, 2 );
add_filter( 'gutenberg_can_edit_post_type', array( &$this, 'gutenberg_support' ), 10, 2 );
add_filter( 'use_block_editor_for_post_type', [&$this, 'gutenberg_support'], 10, 2 );
add_filter( 'gutenberg_can_edit_post_type', [&$this, 'gutenberg_support'], 10, 2 );
}

public function gutenberg_support( $can_edit, $post_type ){

public function gutenberg_support( $can_edit, $post_type ) {
if ( $post_type == 'cp_recipe' )
return false;

return $can_edit;

}

}
4 changes: 1 addition & 3 deletions includes/class.cooked-measurements.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Cooked_Measurements {
public static function get() {

// Use the "cooked_measurements" filter to add your own measurements.
$measurements = apply_filters('cooked_measurements',array(
$measurements = apply_filters('cooked_measurements', array(
'g' => array(
'singular_abbr' => _x('g','Grams Abbreviation (Singular)','cooked'),
'plural_abbr' => _x('g','Grams Abbreviation (Plural)','cooked'),
Expand Down Expand Up @@ -533,7 +533,6 @@ public function fraction_cleaner($fraction) {
$closest_decimal = self::get_closest_decimal( $decimal, $decimal_array );

switch($closest_decimal):

case 0.125:
return '1/8';
case 0.166:
Expand All @@ -552,7 +551,6 @@ public function fraction_cleaner($fraction) {
return '3/4';
case 0.875:
return '7/8';

endswitch;
else:
return self::calculate($decimal, 'fraction');
Expand Down
8 changes: 4 additions & 4 deletions includes/class.cooked-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
class Cooked_Widgets {

public function __construct() {
add_action( 'widgets_init', array(&$this, 'register_widgets'), 10, 1 );
add_action( 'widgets_init', [&$this, 'register_widgets'], 10, 1 );
}

public function register_widgets() {
$widgets = apply_filters( 'cooked_widgets', array(
$widgets = apply_filters( 'cooked_widgets', [
'Cooked_Widget_Nutrition',
'Cooked_Widget_Search',
'Cooked_Widget_Recipe_List',
'Cooked_Widget_Recipe_Categories',
'Cooked_Widget_Recipe_Card',
));
]);
if ( !empty($widgets) ):
foreach( $widgets as $widget ):
register_widget( $widget );
Expand All @@ -38,7 +38,7 @@ public static function recipe_finder( $field_id = '', $field_name = '', $include
echo '<div style="margin:-10px 0 0 0;"><a href="#" class="button cooked-recipe-finder-show" id="' . esc_attr( $field_id ) . '-SHOW">' . esc_html( $button_title ) . '</a></div>';
echo '<select multiple class="widefat cooked-recipe-finder" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" placeholder="' . __( 'Choose recipe(s)...', 'cooked' ) . '">';
if ( !empty( $included ) ):
foreach( $included as $recipe ):
foreach ( $included as $recipe ):
$_recipe = Cooked_Recipes::get( $recipe, true );
echo '<option selected="selected" value="' . esc_attr( $_recipe['id'] ) . '">' . esc_html( $_recipe['title'] ) . '</option>';
endforeach;
Expand Down
12 changes: 11 additions & 1 deletion templates/admin/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
?></h1>
<?php
/* translators: referring to "Cooked", "Settings" and "Documentation" */
echo wpautop( sprintf(__('If this is your first time using %1$s, head over to the %2$s page for some initial configuration. You can also check out the %3$s if you get stuck. If you just recently updated, you can find out what\'s new below.','cooked'),'Cooked','<a href="' . untrailingslashit( admin_url() ) . '/admin.php?page=cooked_settings">' . __( 'Settings', 'cooked' ) . '</a>', '<a href="https://github.com/XjSv/Cooked/wiki" target="_blank">' . __( 'documentation','cooked' ) . '</a>' ) ); ?>
echo wpautop(
sprintf(
__('If this is your first time using %1$s, head over to the %2$s page for some initial configuration. You can also check out the %3$s if you get stuck or contact me on %4$s. If you just recently updated, you can find out what\'s new below.', 'cooked'),
'Cooked',
'<a href="' . untrailingslashit( admin_url() ) . '/admin.php?page=cooked_settings">' . __( 'Settings', 'cooked' ) . '</a>',
'<a href="https://github.com/XjSv/Cooked/wiki" target="_blank">' . __( 'documentation', 'cooked' ) . '</a>' ,
'<a href="https://discord.gg/qdGwXaXxc6" target="_blank">' . __( 'Discord', 'cooked' ) . '</a>'
)
);
?>
</div>

<div class="cooked-welcome-panel-content">
Expand All @@ -20,6 +29,7 @@
<h4><?php _e( 'Quick Links', 'cooked' ); ?></h4>
<ul>
<li><i class="cooked-icon cooked-icon-link-lt cooked-icon-fw"></i>&nbsp;&nbsp;<a href="https://github.com/XjSv/Cooked/wiki" target="_blank"><?php _e( 'Documentation','cooked' ); ?></a></li>
<li><i class="cooked-icon cooked-icon-comment cooked-icon-fw"></i>&nbsp;&nbsp;<a href="https://discord.gg/qdGwXaXxc6" target="_blank"><?php _e( 'Discord','cooked' ); ?></a></li>
<li><i class="cooked-icon cooked-icon-gear cooked-icon-fw"></i>&nbsp;&nbsp;<a href="<?php echo admin_url('admin.php?page=cooked_settings'); ?>"><?php _e('Cooked Settings','cooked'); ?></a></li>
<li><i class="cooked-icon cooked-icon-pencil cooked-icon-fw"></i>&nbsp;&nbsp;<a href="<?php echo admin_url('post-new.php?post_type=cp_recipe'); ?>"><?php _e('Create a Recipe','cooked'); ?></a></li>
<?php if ( !class_exists( 'Cooked_Pro_Plugin' ) ): ?><li class="cooked-pro"><i class="cooked-icon cooked-icon-star-lg cooked-icon-fw"></i>&nbsp;&nbsp;<a href="<?php echo admin_url('admin.php?page=cooked_pro'); ?>"><?php esc_html_e('Upgrade to Pro','cooked'); ?></a></li><?php endif; ?>
Expand Down

0 comments on commit 0d24df1

Please sign in to comment.