Skip to content

Commit

Permalink
Merge branch 'development' into feat/pro/688
Browse files Browse the repository at this point in the history
  • Loading branch information
HardeepAsrani authored Dec 28, 2024
2 parents 95c629c + 4a6071c commit ceee2fd
Show file tree
Hide file tree
Showing 12 changed files with 558 additions and 123 deletions.
27 changes: 27 additions & 0 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ fieldset[disabled] .form-control {
.fz-form-wrap .form-block .only-pro-content .only-pro-container .upgrade-alert{
width: 100%;
}
#fz-features .fz-form-wrap .form-block .only-pro-content .only-pro-container{
width: 100%;
}

.form-block-pro-text{
padding-top: 8px;
Expand Down Expand Up @@ -1216,6 +1219,30 @@ input.fz-switch-toggle[type=checkbox]:checked:before{
padding-left: 12px;
padding-right: 12px;
}
.fz-auto-cat {
width: 100%;
}
.fz-auto-cat .fz-select-control {
min-width: auto;
}
.fz-auto-cat tr {
display: flex;
gap: 12px;
padding: 6px 0;
}
.fz-auto-cat .fz-auto-cat-col-8{
width: 66.66%;
}
.fz-auto-cat .fz-auto-cat-col-4{
width: 33.34%;
display: flex;
gap: 6px;
}
.fz-auto-cat-actions {
display: flex;
padding-top: 12px;
justify-content: flex-end;
}

.support-box-list{
padding: 30px 0 24px;
Expand Down
14 changes: 14 additions & 0 deletions includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,12 +995,26 @@ private function save_settings() {
$settings = apply_filters( 'feedzy_get_settings', array() );
switch ( $post_tab ) {
case 'general':
$auto_categories = isset( $_POST['auto-categories'] ) ? filter_input( INPUT_POST, 'auto-categories', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY ) : array();

$auto_categories = array_filter( $auto_categories, function( $item ) {
return ! empty( $item['keywords'] ) && is_numeric( $item['category'] );
});

$auto_categories = array_map(function( $item ) {
$item['keywords'] = sanitize_text_field( $item['keywords'] );
return $item;
}, $auto_categories );

$auto_categories = array_values( $auto_categories );

$settings['general']['disable-default-style'] = isset( $_POST['disable-default-style'] ) ? (int) filter_input( INPUT_POST, 'disable-default-style', FILTER_SANITIZE_NUMBER_INT ) : '';
$settings['general']['feedzy-delete-days'] = isset( $_POST['feedzy-delete-days'] ) ? (int) filter_input( INPUT_POST, 'feedzy-delete-days', FILTER_SANITIZE_NUMBER_INT ) : '';
$settings['general']['default-thumbnail-id'] = isset( $_POST['default-thumbnail-id'] ) ? (int) filter_input( INPUT_POST, 'default-thumbnail-id', FILTER_SANITIZE_NUMBER_INT ) : 0;
$settings['general']['fz_cron_execution'] = isset( $_POST['fz_cron_execution'] ) ? sanitize_text_field( wp_unslash( $_POST['fz_cron_execution'] ) ) : '';
$settings['general']['fz_cron_schedule'] = isset( $_POST['fz_cron_schedule'] ) ? filter_input( INPUT_POST, 'fz_cron_schedule', FILTER_UNSAFE_RAW ) : 'hourly';
$settings['general']['fz_execution_offset'] = isset( $_POST['fz_execution_offset'] ) ? filter_input( INPUT_POST, 'fz_execution_offset', FILTER_UNSAFE_RAW ) : '';
$settings['general']['auto-categories'] = $auto_categories;
$settings['general']['feedzy-telemetry'] = isset( $_POST['feedzy-telemetry'] ) ? (int) filter_input( INPUT_POST, 'feedzy-telemetry', FILTER_SANITIZE_NUMBER_INT ) : '';
break;
case 'headers':
Expand Down
94 changes: 89 additions & 5 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ public function enqueue_styles() {
'clearLogButton' => __( 'Clear Log', 'feedzy-rss-feeds' ),
'okButton' => __( 'Ok', 'feedzy-rss-feeds' ),
'removeErrorLogsMsg' => __( 'Removed all error logs.', 'feedzy-rss-feeds' ),
'importButton' => sprintf(
'<a href="#" class="page-title-action fz-export-import-btn%1$s"><span class="dashicons %2$s"></span>%3$s</a>',
! feedzy_is_pro() ? ' only-pro' : '',
feedzy_is_pro() ? 'dashicons-upload' : 'dashicons-lock',
esc_html__( 'Import Job', 'feedzy-rss-feeds' )
),
),
)
);
Expand Down Expand Up @@ -403,6 +409,10 @@ public function feedzy_import_feed_options() {
$import_content = '[[{"value":"%5B%7B%22id%22%3A%22%22%2C%22tag%22%3A%22item_content%22%2C%22data%22%3A%7B%7D%7D%5D"}]]';
}

if ( feedzy_is_pro() && empty( $import_post_term ) ) {
$import_post_term = '[#auto_categories]';
}

$import_link_author_admin = get_post_meta( $post->ID, 'import_link_author_admin', true );
$import_link_author_public = get_post_meta( $post->ID, 'import_link_author_public', true );

Expand Down Expand Up @@ -1935,6 +1945,7 @@ function ( $attr, $key ) {

if ( $import_post_term !== 'none' && strpos( $import_post_term, '_' ) > 0 ) {
$terms = explode( ',', $import_post_term );
$terms = apply_filters( 'feedzy_import_terms', $terms, $item );
$terms = array_filter(
$terms,
function( $term ) {
Expand All @@ -1944,6 +1955,9 @@ function( $term ) {
if ( false !== strpos( $term, '[#item_' ) ) {
return;
}
if ( false !== strpos( $term, '[#auto_categories]' ) ) {
return;
}
return $term;
}
);
Expand Down Expand Up @@ -2476,6 +2490,11 @@ public function admin_notices() {
if ( false === Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled( 'feedzy_cron' ) ) {
echo wp_kses_post( '<div class="notice notice-error"><p>' . __( 'Unable to register cron job. Your feeds might not get updated', 'feedzy-rss-feeds' ) . '</p></div>' );
}

// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! empty( $_GET['imported'] ) ) {
echo wp_kses_post( '<div class="notice notice-success is-dismissible"><p>' . __( 'Successfully imported.', 'feedzy-rss-feeds' ) . '</p></div>' );
}
}

/**
Expand Down Expand Up @@ -2843,12 +2862,12 @@ public function add_import_actions( $actions, $post ) {
unset( $actions['inline hide-if-no-js'] );

$actions['feedzy_purge'] = sprintf(
'<a href="#" class="feedzy-purge" data-id="%d">%2$s</a><span class="feedzy-spinner spinner"></span>',
'<a href="#" class="feedzy-purge" data-id="%d">%2$s</a>',
$post->ID,
esc_html( __( 'Purge &amp; Reset', 'feedzy-rss-feeds' ) )
);
if ( feedzy_is_pro() ) {

if ( feedzy_is_pro() ) {
$actions['feedzy_clone'] =
sprintf(
'<a href="%1$s" class="feedzy-clone" >%2$s</a>',
Expand Down Expand Up @@ -2882,6 +2901,25 @@ public function add_import_actions( $actions, $post ) {
$is_not_first = true;
}
}
// Export action.
$export_action = sprintf(
'<a href="%s" class="%s"style="%s">%s</a>',
feedzy_is_pro() ? esc_url(
add_query_arg(
array(
'action' => 'fz_export_job',
'_wpnonce' => wp_create_nonce( 'fz_export_job' ),
'id' => $post->ID,
),
admin_url( 'admin.php' )
)
) : '#',
feedzy_is_pro() ? 'fz-export-btn' : 'fz-export-btn-pro',
! feedzy_is_pro() ? 'opacity:0.5;' : '',
( ! feedzy_is_pro() ? '<span style="font-size: 13px;line-height: 1.5em;width: 13px;height: 13px;" class="dashicons dashicons-lock"></span>' : '' ) . esc_html__( 'Export', 'feedzy-rss-feeds' )
);

$actions['export'] = $export_action;
} elseif ( 1 === intval( get_post_meta( $post->ID, 'feedzy', true ) ) ) {
// show an unclickable action that mentions that it is imported by us
// so that users are aware
Expand Down Expand Up @@ -3296,10 +3334,9 @@ private function wizard_import_feed() {

if ( ! is_wp_error( $job_id ) ) {
update_post_meta( $job_id, 'source', $wizard_data['feed'] );
update_post_meta( $job_id, 'import_post_title', '[#item_title]' );
update_post_meta( $job_id, 'import_post_title', '[[{"value":"%5B%7B%22id%22%3A%22%22%2C%22tag%22%3A%22item_title%22%2C%22data%22%3A%7B%7D%7D%5D"}]]' );
update_post_meta( $job_id, 'import_post_date', '[#item_date]' );
update_post_meta( $job_id, 'import_post_content', '[#item_content]' );
update_post_meta( $job_id, 'import_post_content', '[#item_content]' );
update_post_meta( $job_id, 'import_post_content', '[[{"value":"%5B%7B%22id%22%3A%22%22%2C%22tag%22%3A%22item_content%22%2C%22data%22%3A%7B%7D%7D%5D"}]]' );
update_post_meta( $job_id, 'import_post_type', $post_type );
update_post_meta( $job_id, 'import_post_status', 'publish' );
update_post_meta( $job_id, 'import_post_featured_img', '[#item_image]' );
Expand Down Expand Up @@ -3347,4 +3384,51 @@ private function clear_error_logs() {
)
);
}

/**
* Load edit screen.
*/
public function load_edit_screen() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( empty( $_GET['post_type'] ) || 'feedzy_imports' !== $_GET['post_type'] ) {
return;
}
add_action( 'admin_footer', array( $this, 'add_import_export_section' ) );
}

/**
* Add import export section.
*/
public function add_import_export_section() {
if ( ! feedzy_is_pro() ) :
?>
<div id="fz_import_export_upsell" class="hidden" style="max-width:450px">
<div class="modal-content">
<span class="notice-dismiss close-modal">
<span class="screen-reader-text"><?php esc_html_e( 'Dismiss this dialog', 'feedzy-rss-feeds' ); ?></span>
</span>
<div class="modal-header">
<h2><span class="dashicons dashicons-lock"></span> <?php esc_html_e( 'Import/Export is a PRO feature', 'feedzy-rss-feeds' ); ?></h2>
</div>
<div class="modal-body">
<p><?php esc_html_e( 'We\'re sorry, import/export is not available on your plan. Please upgrade to the Pro plan to unlock all these features.', 'feedzy-rss-feeds' ); ?></p>
</div>
<div class="modal-footer">
<div class="button-container"><a href="<?php echo esc_url( tsdk_translate_link( tsdk_utmify( FEEDZY_UPSELL_LINK, 'importExport' ) ) ); ?>" target="_blank" rel="noopener " class="button button-primary button-large"><?php esc_html_e( 'Upgrade to PRO', 'feedzy-rss-feeds' ); ?><span aria-hidden="true" class="dashicons dashicons-external"></span></a></div>
</div>
</div>
</div>
<?php endif; ?>
<script type="template/text" id="fz_import_field_section">
<div class="fz-import-field hidden">
<form method="post" enctype="multipart/form-data" action="<?php echo esc_url( add_query_arg( array( 'action' => 'fz_import_job' ), admin_url( 'admin.php' ) ) ); ?>">
<h4> <?php esc_html_e( 'Choose the inport job .json file to import.', 'feedzy-rss-feeds' ); ?></h4>
<?php wp_nonce_field( 'fz_import_job' ); ?>
<input type="file" accept=".json" name="fz_import" required>
<button type="submit" class="button button-primary"><?php esc_html_e( 'Import', 'feedzy-rss-feeds' ); ?></button>
</form>
</div>
</script>
<?php
}
}
2 changes: 1 addition & 1 deletion includes/feedzy-rss-feeds-feed-tweaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ function feedzy_is_legacyv5( ) {

return $legacy === 1;
}

/**
* Check if the user is pro or not.
*
* @return bool If the users is pro or not
*/
function feedzy_is_pro( $check_license = true ) {

$status = apply_filters( 'product_feedzy_license_status', false ) === 'valid';
if ( ! $check_license ) {
$status = true;
Expand Down
1 change: 1 addition & 0 deletions includes/feedzy-rss-feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function () {
self::$instance->loader->add_filter( 'feedzy_magic_tags_post_excerpt', $plugin_import, 'magic_tags_post_excerpt', 11 );
self::$instance->loader->add_action( 'admin_action_feedzy_clone_import_job', $plugin_import, 'feedzy_clone_import_job' );
self::$instance->loader->add_action( 'admin_notices', $plugin_import, 'feedzy_import_clone_success_notice' );
self::$instance->loader->add_action( 'load-edit.php', $plugin_import, 'load_edit_screen' );
// Remove elementor feature.
self::$instance->loader->add_action( 'elementor/experiments/feature-registered', self::$instance->admin, 'feedzy_remove_elementor_feature', 10, 2 );
// Remove widget.
Expand Down
52 changes: 52 additions & 0 deletions includes/layouts/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"><?php e

$feedzy_delete_days = isset( $settings['general']['feedzy-delete-days'] ) ? $settings['general']['feedzy-delete-days'] : 0;
$default_thumbnail_id = isset( $settings['general']['default-thumbnail-id'] ) ? $settings['general']['default-thumbnail-id'] : 0;
$mapped_categories = isset( $settings['general']['auto-categories'] ) && ! empty( $settings['general']['auto-categories'] ) ? $settings['general']['auto-categories'] : array(
array(
'keywords' => '',
'category' => '',
),
);
$categories = get_categories(
array(
'hide_empty' => false,
)
);
$telemetry_enabled = get_option( 'feedzy_rss_feeds_logger_flag', 0 );

switch ( $active_tab ) {
Expand Down Expand Up @@ -155,6 +166,47 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"><?php e
<div class="help-text pt-8"><?php esc_html_e( 'This setting will be used to inherit the current theme style instead of the default style. If disabled, it will be considered the individual widget/block/shortcode setting.', 'feedzy-rss-feeds' ); ?></div>
</div>
</div>
<div class="form-block <?php echo esc_attr( apply_filters( 'feedzy_upsell_class', '' ) ); ?>">
<?php echo wp_kses_post( apply_filters( 'feedzy_upsell_content', '', 'auto-categories', 'settings' ) ); ?>
<div class="fz-form-group">
<label class="form-label"><?php esc_html_e( 'Auto Categories Mapping', 'feedzy-rss-feeds' ); ?></label>
<table class="fz-auto-cat">
<tbody>
<?php foreach ( $mapped_categories as $index => $category_mapping ) : ?>
<tr>
<td class="fz-auto-cat-col-8">
<input type="text" name="auto-categories[<?php echo esc_attr( $index ); ?>][keywords]" class="form-control" placeholder="<?php esc_attr_e( 'Values separated by commas', 'feedzy-rss-feeds' ); ?>" value="<?php echo esc_attr( $category_mapping['keywords'] ); ?>"/>
</td>
<td class="fz-auto-cat-col-4">
<select name="auto-categories[<?php echo esc_attr( $index ); ?>][category]" class="form-control fz-select-control">
<option value=""><?php esc_html_e( 'Select a category', 'feedzy-rss-feeds' ); ?></option>
<?php
foreach ( $categories as $category ) {
$selected = $category->term_id == $category_mapping['category'] ? 'selected' : '';
echo '<option value="' . esc_attr( $category->term_id ) . '" ' . esc_attr( $selected ) . '>' . esc_html( $category->name ) . '</option>';
}
?>
</select>
<button type="button" class="btn btn-outline-primary<?php echo $index === 0 ? ' disabled' : ''; ?>" <?php echo $index === 0 ? 'disabled' : ''; ?>><?php esc_html_e( 'Delete', 'feedzy-rss-feeds' ); ?></button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="fz-auto-cat-actions">
<button type="button"class="btn btn-outline-primary"><?php esc_html_e( 'Add New', 'feedzy-rss-feeds' ); ?></button>
</div>
<div class="help-text pt-8">
<?php
printf(
// translators: %s is a placeholder for the auto categories tag, like [#auto_categories].
esc_html__( 'Automatically assign categories to your posts based on their titles. You need to add %s tag to the category field of your import to support this feature.', 'feedzy-rss-feeds' ),
'<strong>[#auto_categories]</strong>'
);
?>
</div>
</div>
</div>
<?php if ( feedzy_is_pro() ) : ?>
<div class="form-block">
<div class="fz-form-group">
Expand Down
63 changes: 63 additions & 0 deletions includes/views/css/import-metabox-edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,66 @@ span.feedzy-spinner {
.feedzy-errors-dialog + .ui-widget-content button.feedzy-clear-logs {
margin-left: 0;
}

.wp-core-ui .fz-export-import-btn {
display: inline-flex !important;
align-items: center;
}

.wp-core-ui .fz-header-action {
display: inline-flex !important;
gap: 8px;
}

#fz_import_export_upsell .modal-content {
background: #fff;
border-radius: 3px;]
width: auto;
margin: 1.75rem auto ;
}
#fz_import_export_upsell .modal-body {
text-align: center;
}
#fz_import_export_upsell .modal-header {
padding-bottom: 10px;
margin-bottom: 10px;
position: relative;
}
#fz_import_export_upsell .modal-header .dashicons {
font-size: 1.3em;
line-height: inherit;
}
#fz_import_export_upsell .modal-header h2 {
text-align: center;
}
#fz_import_export_upsell .close-modal {
position: absolute;
top: 0;
right: 0;
}
#fz_import_export_upsell .modal-footer .dashicons{

vertical-align: middle;
font-size: initial;
}
#fz_import_export_upsell .modal-footer {
padding-top: 10px;
margin-top: 10px;
text-align: center;
}
.fz-import-field {
background-color: #fff;
max-width: 400px;
width: 100%;
margin: 0 auto;
position: relative;
padding: 15px;
height: 120px;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.fz-import-field.hidden {
display: none;
}
Loading

0 comments on commit ceee2fd

Please sign in to comment.