Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep-plugin-file-under-80-kb #1785

Merged
merged 2 commits into from
Oct 10, 2024
Merged
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 includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if (! defined('PP_LOADED')) {
if (! defined('PUBLISHPRESS_VERSION')) {
// Define constants
define('PUBLISHPRESS_VERSION', '4.5.0');
define('PUBLISHPRESS_VERSION', '4.5.0.1');
define('PUBLISHPRESS_BASE_PATH', __DIR__);
define('PUBLISHPRESS_VIEWS_PATH', __DIR__ . '/views');
define('PUBLISHPRESS_FILE_PATH', PUBLISHPRESS_BASE_PATH . '/publishpress.php');
Expand Down
287 changes: 15 additions & 272 deletions modules/calendar/calendar.php

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion modules/calendar/library/calendar-methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ public function enqueue_admin_scripts($method_args)
);



if (! isset($wp_scripts->queue['react'])) {
wp_enqueue_script(
'react',
Expand Down
291 changes: 291 additions & 0 deletions modules/calendar/library/calendar-utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,297 @@ public static function get_ending_of_week($date, $format = 'Y-m-d', $week = 1)
return $formatted_end_of_week;
}

public static function getPostData($args) {
$id = $args['id'];
$post = $args['post'];
$type = $args['type'];
$date = $args['date'];
$status = $args['status'];
$categories = $args['categories'];
$tags = $args['tags'];

$authorsNames = apply_filters(
'publishpress_post_authors_names',
[get_the_author_meta('display_name', $post->post_author)],
$id
);

$data = [
'id' => $id,
'status' => $post->post_status,
'fields' => [
'type' => [
'label' => __('Post Type', 'publishpress'),
'value' => $type,
'type' => 'type',
],
'id' => [
'label' => __('ID', 'publishpress'),
'value' => $id,
'type' => 'number',
],
'date' => [
'label' => __('Date', 'publishpress'),
'value' => $post->post_date,
'valueString' => $date,
'type' => 'date',
],
'status' => [
'label' => __('Post Status', 'publishpress'),
'value' => $status,
'type' => 'status',
],
'authors' => [
'label' => _n('Author', 'Authors', count($authorsNames), 'publishpress'),
'value' => $authorsNames,
'type' => 'authors',
],
'categories' => [
'label' => _n('Category', 'Categories', count($categories), 'publishpress'),
'value' => $categories,
'type' => 'taxonomy',
],
'tags' => [
'label' => _n('Tag', 'Tags', count($tags), 'publishpress'),
'value' => $tags,
'type' => 'taxonomy',
],
],
'links' => []
];

$postTypeObject = get_post_type_object($post->post_type);

if (current_user_can($postTypeObject->cap->edit_post, $post->ID)) {
$data['links']['edit'] = [
'label' => __('Edit', 'publishpress'),
'url' => htmlspecialchars_decode(get_edit_post_link($id))
];
}

if (current_user_can($postTypeObject->cap->delete_post, $post->ID)) {
$data['links']['trash'] = [
'label' => __('Trash', 'publishpress'),
'url' => htmlspecialchars_decode(get_delete_post_link($id)),
];
}

if (current_user_can($postTypeObject->cap->read_post, $post->ID)) {
if ($post->post_status === 'publish') {
$label = __('View', 'publishpress');
$link = get_permalink($id);
} else {
$label = __('Preview', 'publishpress');
$link = get_preview_post_link($id);
}

$data['links']['view'] = [
'label' => $label,
'url' => htmlspecialchars_decode($link),
];
}

$data = apply_filters('publishpress_calendar_get_post_data', $data, $post);

return $data;
}

public static function add_admin_body_class($classes) {
global $pagenow;
if ('admin.php' === $pagenow && isset($_GET['page']) && $_GET['page'] === 'pp-calendar') {
$classes .= ' pp-content-calendar-page';
}
return $classes;
}

public static function getTimezoneString()
{
$timezoneString = get_option('timezone_string');

if (empty($timezoneString)) {
$offset = get_option('gmt_offset');

if ($offset > 0) {
$offset = '+' . $offset;
}

if (2 === strlen($offset)) {
$offset .= ':00';
}

$timezoneString = new DateTimeZone($offset);
$timezoneString = $timezoneString->getName();
}

return $timezoneString;
}

/**
* Set all post types as selected, to be used as the default option.
*
* @return array
*/
public static function pre_select_all_post_types()
{
$list = get_post_types(null, 'objects');

foreach ($list as $type => $value) {
$list[$type] = 'on';
}

return $list;
}

public static function get_content_calendar_form_filters($args)
{
$content_calendar_datas = $args['content_calendar_datas'];
// custom filters
$filters['custom'] = [
'title' => esc_html__('Custom filters', 'publishpress'),
'message' => esc_html__('Click the "Add New" button to create new filters.', 'publishpress'),
'filters' => $content_calendar_datas['content_calendar_custom_filters']
];

// default filters
$filters['default'] = [
'title' => esc_html__('Inbuilt filters', 'publishpress'),
'filters' => [
'post_status' => esc_html__('Post Status', 'publishpress'),
'author' => esc_html__('Author', 'publishpress'),
'cpt' => esc_html__('Post Type', 'publishpress')
]
];

// editorial fields filters
if (isset($content_calendar_datas['editorial_metadata'])) {
$filters['editorial_metadata'] = [
'title' => esc_html__('Editorial Fields', 'publishpress'),
'message' => esc_html__('You do not have any editorial fields enabled', 'publishpress'),
'filters' => $content_calendar_datas['editorial_metadata']
];
}

$filters['taxonomies'] = [
'title' => esc_html__('Taxonomies', 'publishpress'),
'message' => esc_html__('You do not have any public taxonomies', 'publishpress'),
'filters' => $content_calendar_datas['taxonomies']
];

/**
* @param array $filters
* @param array $content_calendar_datas
*
* @return $filters
*/
$filters = apply_filters('publishpress_content_calendar_form_filters', $filters, $content_calendar_datas);

return $filters;
}

public static function calendar_ics_subs_html($subscription_link) {
?>

<div id="publishpress-calendar-ics-subs" style="display:none;">
<h3><?php
echo esc_html__('PublishPress', 'publishpress'); ?>
- <?php
echo esc_html__('Subscribe in iCal or Google Calendar', 'publishpress'); ?>
</h3>

<div>
<h4><?php
echo esc_html__('Start date', 'publishpress'); ?></h4>
<select id="publishpress-start-date">
<option value="0"
selected="selected"><?php
echo esc_html__('Current week', 'publishpress'); ?></option>
<option value="1"><?php
echo esc_html__('One month ago', 'publishpress'); ?></option>
<option value="2"><?php
echo esc_html__('Two months ago', 'publishpress'); ?></option>
<option value="3"><?php
echo esc_html__('Three months ago', 'publishpress'); ?></option>
<option value="4"><?php
echo esc_html__('Four months ago', 'publishpress'); ?></option>
<option value="5"><?php
echo esc_html__('Five months ago', 'publishpress'); ?></option>
<option value="6"><?php
echo esc_html__('Six months ago', 'publishpress'); ?></option>
</select>

<br/>

<h4><?php
echo esc_html__('End date', 'publishpress'); ?></h4>
<select id="publishpress-end-date">
<optgroup label="<?php
echo esc_attr__('Weeks'); ?>">
<option value="w1"><?php
echo esc_html__('One week', 'publishpress'); ?></option>
<option value="w2"><?php
echo esc_html__('Two weeks', 'publishpress'); ?></option>
<option value="w3"><?php
echo esc_html__('Three weeks', 'publishpress'); ?></option>
<option value="w4"><?php
echo esc_html__('Four weeks', 'publishpress'); ?></option>
</optgroup>

<optgroup label="<?php
echo esc_attr__('Months'); ?>">
<option value="m1"><?php
echo esc_html__('One month', 'publishpress'); ?></option>
<option value="m2"
selected="selected"><?php
echo esc_html__('Two months', 'publishpress'); ?></option>
<option value="m3"><?php
echo esc_html__('Three months', 'publishpress'); ?></option>
<option value="m4"><?php
echo esc_html__('Four months', 'publishpress'); ?></option>
<option value="m5"><?php
echo esc_html__('Five months', 'publishpress'); ?></option>
<option value="m6"><?php
echo esc_html__('Six months', 'publishpress'); ?></option>
<option value="m7"><?php
echo esc_html__('Seven months', 'publishpress'); ?></option>
<option value="m8"><?php
echo esc_html__('Eight months', 'publishpress'); ?></option>
<option value="m9"><?php
echo esc_html__('Nine months', 'publishpress'); ?></option>
<option value="m10"><?php
echo esc_html__('Ten months', 'publishpress'); ?></option>
<option value="m11"><?php
echo esc_html__('Eleven months', 'publishpress'); ?></option>
<option value="m12"><?php
echo esc_html__('Twelve months', 'publishpress'); ?></option>
</optgroup>
</select>
</div>

<br/>

<a href="<?php
echo esc_url($subscription_link); ?>" id="publishpress-ics-download"
style="margin-right: 20px;" class="button">
<span class="dashicons dashicons-download" style="text-decoration: none"></span>
<?php
echo esc_html__('Download .ics file', 'publishpress'); ?></a>

<button data-clipboard-text="<?php
echo esc_attr($subscription_link); ?>" id="publishpress-ics-copy"
class="button-primary">
<span class="dashicons dashicons-clipboard" style="text-decoration: none"></span>
<?php
echo esc_html__('Copy to the clipboard', 'publishpress'); ?>
</button>
</div>

<a href="#TB_inline?width=550&height=270&inlineId=publishpress-calendar-ics-subs" class="thickbox">
<?php
echo esc_html__('Click here to subscribe in iCal or Google Calendar', 'publishpress'); ?>
</a>
<?php
}

}

}
38 changes: 1 addition & 37 deletions modules/content-board/content-board.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function init()
add_action('admin_init', [$this->content_board_methods, 'handle_form_date_range_change']);

// Register our settings
add_action('admin_init', [$this, 'register_settings']);
add_action('admin_init', [$this->content_board_methods, 'register_settings']);

add_action('wp_ajax_publishpress_content_board_search_authors', [$this, 'sendJsonSearchAuthors']);
add_action('wp_ajax_publishpress_content_board_search_categories', [$this, 'sendJsonSearchCategories']);
Expand Down Expand Up @@ -253,42 +253,6 @@ public function setDefaultCapabilities()
}
}

/**
* Register settings for notifications so we can partially use the Settings API
* (We use the Settings API for form generation, but not saving)
*
* @since 0.7
* @uses add_settings_section(), add_settings_field()
*/
public function register_settings()
{
add_settings_section(
$this->module->options_group_name . '_general',
false,
'__return_false',
$this->module->options_group_name
);

add_settings_field(
'post_types',
esc_html__('Post types to show:', 'publishpress'),
[$this, 'settings_post_types_option'],
$this->module->options_group_name,
$this->module->options_group_name . '_general'
);
}

/**
* Choose the post types for editorial fields
*
* @since 0.7
*/
public function settings_post_types_option()
{
global $publishpress;
$publishpress->settings->helper_option_custom_post_type($this->module);
}

/**
* Get the post types for editorial fields
*
Expand Down
Loading
Loading