Skip to content

Commit

Permalink
Merge pull request #765 from publishpress/release-2.14.0
Browse files Browse the repository at this point in the history
* Bump webpack from 5.91.0 to 5.94.0 (#749)

Bumps [webpack](https://github.com/webpack/webpack) from 5.91.0 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.91.0...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix/#740_character_count_issue (#750)

* feature/#639_ACF_Integration_Support (#762)

* features/#616_minimum_number_of_characters_for_alt_text (#753)

* fix/#752_php_82_deprecated_message (#754)

* fix deprecated message

* fix group name on Yoast checklists

* change interpolation to string concat

---------

Co-authored-by: Richa Ferry Setyawan <[email protected]>

* features/#747_add_taxonomies_tab (#761)

* add taxonomies tabs

* hide empty tab

---------

Co-authored-by: Richa Ferry Setyawan <[email protected]>

* composer update

* bump version & update changelog

* fix failed save rule

* fix undefined disable_publish_button

* fix/#766_tiny_text_change_for_new_alt_text (#769)

* composer update

* composer update

* fix/#770_hide_checklist_from_acf (#773)

* fix/rename_field_group_tobe_acf (#774)

* update changelog

composer update

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Riza Maulana Ardiyanto <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2024
2 parents 17b1ac7 + a257f03 commit 9892db8
Show file tree
Hide file tree
Showing 24 changed files with 840 additions and 540 deletions.
170 changes: 85 additions & 85 deletions composer.lock

Large diffs are not rendered by default.

47 changes: 24 additions & 23 deletions core/Legacy/Module.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @package PublishPress\Checklistss
* @author PublishPress <[email protected]>
Expand Down Expand Up @@ -53,9 +54,9 @@ public function clearPostTypesOptions($modulePostTypes = [], $postTypeSupport =
$allPostTypes = array_keys($this->getAllPostTypes());
foreach ($allPostTypes as $postType) {
if ((isset($modulePostTypes[$postType]) && $modulePostTypes[$postType] == 'on') || post_type_supports(
$postType,
$postTypeSupport
)) {
$postType,
$postTypeSupport
)) {
$normalizedPostTypeOptions[$postType] = 'on';
} else {
$normalizedPostTypeOptions[$postType] = 'off';
Expand Down Expand Up @@ -222,8 +223,8 @@ public function printDefaultHeader($current_module, $custom_text = null)

if ($message && isset($current_module->messages[$message])) {
$display_text .= '<div class="is-dismissible notice notice-info"><p>' . esc_html(
$current_module->messages[$message]
) . '</p></div>';
$current_module->messages[$message]
) . '</p></div>';
}

// If there's been an error, let's display it
Expand All @@ -238,31 +239,31 @@ public function printDefaultHeader($current_module, $custom_text = null)
}
if ($error && isset($current_module->messages[$error])) {
$display_text .= '<div class="is-dismissible notice notice-error"><p>' . esc_html(
$current_module->messages[$error]
) . '</p></div>';
$current_module->messages[$error]
) . '</p></div>';
}
?>
?>

<div class="publishpress-checklists-admin pressshack-admin-wrapper wrap">
<header>
<h1 class="wp-heading-inline"><?php echo esc_html($current_module->title); ?></h1>
<header>
<h1 class="wp-heading-inline"><?php echo esc_html($current_module->title); ?></h1>

<?php echo !empty($display_text) ? esc_html($display_text) : ''; ?>
<?php // We keep the H2 tag to keep notices tied to the header
?>
<h2>
<?php echo !empty($display_text) ? esc_html($display_text) : ''; ?>
<?php // We keep the H2 tag to keep notices tied to the header
?>
<h2>

<?php if ($current_module->short_description && empty($custom_text)): ?>
<?php echo esc_html($current_module->short_description); ?>
<?php endif; ?>
<?php if ($current_module->short_description && empty($custom_text)): ?>
<?php echo esc_html($current_module->short_description); ?>
<?php endif; ?>

<?php if (!empty($custom_text)) : ?>
<?php echo esc_html($custom_text); ?>
<?php endif; ?>
</h2>
<?php if (!empty($custom_text)) : ?>
<?php echo esc_html($custom_text); ?>
<?php endif; ?>
</h2>

</header>
<?php
</header>
<?php
}

/**
Expand Down
31 changes: 17 additions & 14 deletions core/Legacy/Util.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @package PublishPress\Checklistss
* @author PublishPress <[email protected]>
Expand Down Expand Up @@ -31,9 +32,11 @@ public static function getCurrentPostType()
$post_type = $current_screen->post_type;
} elseif (isset($_REQUEST['post_type'])) {
$post_type = sanitize_key($_REQUEST['post_type']);
} elseif ('post.php' == $pagenow
} elseif (
'post.php' == $pagenow
&& $post_id
&& !empty(get_post($post_id)->post_type)) {
&& !empty(get_post($post_id)->post_type)
) {
$post_type = get_post($post_id)->post_type;
} elseif ('edit.php' == $pagenow && empty($_REQUEST['post_type'])) {
$post_type = 'post';
Expand Down Expand Up @@ -167,7 +170,7 @@ private static function getDirectorySeparator()
*/
public static function ppch_pro_sidebar()
{
?>
?>
<div class="ppch-advertisement-right-sidebar">
<div class="advertisement-box-content postbox ppch-advert">
<div class="postbox-header ppch-advert">
Expand Down Expand Up @@ -222,16 +225,16 @@ class="advert-link" href="https://publishpress.com/docs-category/checklists/" ta
</div>
</div>
</div><?php
}
}

/**
* Check if Checklists Pro active
*/
public static function isChecklistsProActive()
{
if (defined('PPCHPRO_VERSION')) {
return true;
/**
* Check if Checklists Pro active
*/
public static function isChecklistsProActive()
{
if (defined('PPCHPRO_VERSION')) {
return true;
}
return false;
}
}
return false;
}
}
93 changes: 93 additions & 0 deletions core/Requirement/Image_alt_count.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* @package PublishPress\Checklists
* @author PublishPress <[email protected]>
* @copyright copyright (C) 2023 PublishPress. All rights reserved.
* @license GPLv2 or later
* @since 1.0.0
*/

namespace PublishPress\Checklists\Core\Requirement;

defined('ABSPATH') or die('No direct script access allowed.');

class Image_alt_count extends Base_counter
{
/**
* The name of the requirement, in a slug format
*
* @var string
*/
public $name = 'image_alt_count';

/**
* The name of the group, used for the tabs
*
* @var string
*/
public $group = 'images';

/**
* @var int
*/
public $position = 135;

/**
* Initialize the language strings for the instance
*
* @return void
*/
public function init_language()
{
$this->lang['label'] = __('Number of characters in Alt text', 'publishpress-checklists');
$this->lang['label_settings'] = __('Number of characters in Alt text', 'publishpress-checklists');
$this->lang['label_min_singular'] = __('Minimum of %d character in Alt text', 'publishpress-checklists');
$this->lang['label_min_plural'] = __('Minimum of %d characters in Alt text', 'publishpress-checklists');
$this->lang['label_max_singular'] = __('Maximum of %d character in Alt text', 'publishpress-checklists');
$this->lang['label_max_plural'] = __('Maximum of %d characters in Alt text', 'publishpress-checklists');
$this->lang['label_exact_singular'] = __('%d character in Alt text', 'publishpress-checklists');
$this->lang['label_exact_plural'] = __('%d characters in Alt text', 'publishpress-checklists');
$this->lang['label_between'] = __('Between %d and %d characters in Alt text', 'publishpress-checklists');
}

/**
* Returns the current status of the requirement.
*
* @param stdClass $post
* @param mixed $option_value
*
* @return mixed
*/
public function get_current_status($post, $option_value)
{
$alt_lengths = $this->get_image_alt_lengths($post->post_content);

foreach ($alt_lengths as $length) {
if ($length < $option_value[0] || ($option_value[1] > 0 && $length > $option_value[1])) {
return false;
}
}

return true;
}

/**
* Get the lengths of alt text for all images in the content
*
* @param string $content
*
* @return array
*/
private function get_image_alt_lengths($content)
{
$lengths = [];

if (preg_match_all('/<img[^>]+alt=([\'"])(.*?)\1[^>]*>/i', $content, $matches)) {
foreach ($matches[2] as $alt_text) {
$lengths[] = strlen(trim($alt_text));
}
}

return $lengths;
}
}
Loading

0 comments on commit 9892db8

Please sign in to comment.