Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
c4f7c08
Draft
shervElmi Jun 10, 2024
ed6ca4b
Draft2
shervElmi Jun 13, 2024
4ce6f5d
Move the option-box event handler to Core folder
shervElmi Jun 14, 2024
36853fc
Move the request queue helper to Core folder
shervElmi Jun 14, 2024
1854d55
Move the url helpers to Core folder
shervElmi Jun 14, 2024
0f98385
Move the visibility helpers to core folder
shervElmi Jun 14, 2024
88ffc5b
Move the validation helpers to core folder
shervElmi Jun 14, 2024
ea3d29a
Move the form error helpers to core folder
shervElmi Jun 14, 2024
babe6b3
Move global constants to core folder
shervElmi Jun 14, 2024
995ed19
Import dispatchCustomEvent into categoryListener
shervElmi Jun 14, 2024
f81886a
Refactor Form Templates Elements
shervElmi Jun 18, 2024
9063f28
Move the `empty-state.svg` file to `page-skeleton`
shervElmi Jun 18, 2024
8b18ed1
Start refactoring events
shervElmi Jun 18, 2024
ff8b639
Refactor core functionality and complete essential updates
shervElmi Jun 19, 2024
3f355d5
Move addProgressToCardBoxes to core
shervElmi Jun 19, 2024
9678160
Merge remote-tracking branch 'origin/HEAD' into new-add-ons
shervElmi Jun 21, 2024
afabeff
Refactor: Make several classes reusable and update references
shervElmi Jun 21, 2024
16ab8e9
Prepare Add-Ons page assets
shervElmi Jun 21, 2024
fc1d2a9
Fix: enqueue_assets and get_js_variables PHPDocs
shervElmi Jun 21, 2024
27f7604
Add: Cards to the page
shervElmi Jun 25, 2024
0fa132f
Update addon.php
shervElmi Jun 26, 2024
7e21367
Complete: add toggle button
shervElmi Jun 27, 2024
096114b
Add: Addon lock icon
shervElmi Jun 28, 2024
6f16b13
Add categories
shervElmi Jun 28, 2024
fdc7be7
Load categories
shervElmi Jun 28, 2024
44467d3
Setup count of categories
shervElmi Jun 28, 2024
947f058
Update addon.php
shervElmi Jun 28, 2024
474e5e9
Add: All Add-Ons category count
shervElmi Jun 28, 2024
7a46d44
Complete development
shervElmi Jul 1, 2024
0b9dc4f
Fix: Categories count
shervElmi Jul 2, 2024
b77803f
Update: show_upgrade_renew_cta method
shervElmi Jul 2, 2024
f1b14ef
Add request addon text at the list
shervElmi Jul 2, 2024
2835d1d
Add: request addon link
shervElmi Jul 3, 2024
deca286
Fix: Sniffer issues
shervElmi Jul 3, 2024
b1b28ff
Merge remote-tracking branch 'origin/HEAD' into new-add-ons
shervElmi Jul 3, 2024
a7c2523
Fix: formidable_blocks build issue and revert that inside webpack
shervElmi Jul 3, 2024
fa0d57a
Disable toggle button in activating/deactivating state
shervElmi Jul 4, 2024
432151a
Replace static keyword with self
shervElmi Jul 4, 2024
944e36e
Add comment for $plan_required
shervElmi Jul 4, 2024
c097565
Split show_upgrade_renew_cta into smaller methods
shervElmi Jul 4, 2024
589ba0d
fix: Add missing space before PREFIX
shervElmi Jul 4, 2024
1512549
Remove `dispatchCustomEvent` function
shervElmi Jul 4, 2024
17a25f4
Merge remote-tracking branch 'origin/master' into new-add-ons
shervElmi Jul 9, 2024
876880b
Change `frm-page-skeleton-grid-layout` to `frm-list-grid-layout`
shervElmi Jul 9, 2024
52491f3
Remove "page-skeleton.css" and move styles to "frm_admin.css"
shervElmi Jul 9, 2024
b5f911a
Remove redundant default case in switch statement
shervElmi Jul 9, 2024
cf940f0
Remove empty setState and add comment
shervElmi Jul 9, 2024
256c26f
frmPageSkeleton prefix to frmPage
shervElmi Jul 9, 2024
1efcd97
Remove redundant comment from setupInitialView.js
shervElmi Jul 9, 2024
3f4ce65
Add null check for favoritesCategory in elements.js
shervElmi Jul 9, 2024
7e52c0e
Fix minor grid layout issue in desktop-1440px
shervElmi Jul 9, 2024
9c5826a
Fix PHP CS Fixer issue
shervElmi Jul 9, 2024
bab55d5
Merge branch 'master' into new-add-ons
shervElmi Jul 9, 2024
b72dbb7
Update frm_convertkit_icon
shervElmi Jul 9, 2024
3174e91
Clarify `getSingleState` logic
shervElmi Jul 9, 2024
600203f
Create `convertLegacyPackageNames` and refactor
shervElmi Jul 9, 2024
7aff1d1
Add compiled JavaScript files
shervElmi Jul 9, 2024
2030ed7
Fix: search shows no results
shervElmi Jul 11, 2024
9423ab8
Merge remote-tracking branch 'origin/master' into new-add-ons
shervElmi Jul 29, 2024
4e16795
Enhance `elements.js` file
shervElmi Jul 29, 2024
fe1a4be
Optimize add-ons `elements.js` file
shervElmi Jul 29, 2024
be63d1e
Fix all add-ons JS files
shervElmi Jul 29, 2024
58c91cc
Fix all core JS files
shervElmi Jul 29, 2024
0074f6b
Add `get_license_types` method and refactor
shervElmi Jul 30, 2024
44607b1
Convert repeated .${SKELETON_PREFIX}-cat-count class into a variable
shervElmi Jul 30, 2024
24396f1
Optimize: Swap checks for efficiency; check self::$plan_required first
shervElmi Jul 30, 2024
1b9ee3e
Include @return void for static analysis tools
shervElmi Jul 30, 2024
61d412c
Add auto-generated files
shervElmi Jul 30, 2024
8b31b7f
Merge remote-tracking branch 'origin/master' into new-add-ons
shervElmi Jul 30, 2024
e2f6f9c
Add description text to search query
shervElmi Aug 20, 2024
2946211
Merge branch 'master' into new-add-ons
shervElmi Aug 20, 2024
030d65e
Avoid displaying errors on this page
shervElmi Aug 20, 2024
2b5619b
Merge branch 'master' into new-add-ons
shervElmi Aug 21, 2024
c1dd057
Update new cypress tests
shervElmi Aug 21, 2024
2ab189f
Simplify targetButton check using optional chaining
shervElmi Aug 21, 2024
1b06d93
Add auto-generated files
shervElmi Aug 21, 2024
68c0055
Merge remote-tracking branch 'origin/master' into new-add-ons
shervElmi Sep 9, 2024
541e235
Add missing semicolon
shervElmi Sep 9, 2024
8789b9a
Update action name consistency
shervElmi Sep 9, 2024
73cbfbf
Correct text domain to 'formidable'
shervElmi Sep 9, 2024
e61d989
Fix icon issue on the Form Actions page
shervElmi Sep 10, 2024
0571c4e
Merge branch 'master' into new-add-ons
shervElmi Sep 18, 2024
ff53fb3
Change common utilities import to core package
shervElmi Sep 18, 2024
b2eeb65
Update auto-generated files
shervElmi Sep 18, 2024
bd5c3c2
Improve: Onboarding Wizard elements file
shervElmi Sep 18, 2024
983fe65
Update "package-lock.json" file
shervElmi Sep 18, 2024
b6cf70c
Improve accessibility
shervElmi Sep 19, 2024
ec77f00
Merge remote-tracking branch 'origin/master' into new-add-ons
shervElmi Sep 25, 2024
fd9a634
Resolve elements.js
shervElmi Sep 25, 2024
02d8964
Add auto-generated files
shervElmi Sep 25, 2024
592ae7c
Merge branch 'master' into new-add-ons
Crabcyborg Sep 26, 2024
b41eea4
Update `package-lock.json`
shervElmi Sep 30, 2024
4e5ab63
Change Add-Ons color
shervElmi Sep 30, 2024
aab202d
Cypress test update for add-ons page
Crabcyborg Sep 30, 2024
c1d7b8b
Fix Form Templates E2E tests
shervElmi Sep 30, 2024
8dedb68
Update cypress class names
Crabcyborg Sep 30, 2024
dd96c94
Merge branch 'new-add-ons' into cypress_test_updates_for_addons_page
shervElmi Sep 30, 2024
d53f240
Complete merge
shervElmi Sep 30, 2024
457e864
Merge branch 'new-add-ons' into cypress_test_updates_for_addons_page
shervElmi Sep 30, 2024
bc386f7
Fix Form Templates title tests
shervElmi Sep 30, 2024
c84edba
Fix class names
shervElmi Sep 30, 2024
c98805b
Update text class
shervElmi Sep 30, 2024
f0bd0a7
Merge branch 'new-add-ons' into cypress_test_updates_for_addons_page
Crabcyborg Oct 1, 2024
330879b
Get cypress passing
Crabcyborg Oct 1, 2024
f9b7e9a
Merge branch 'cypress_test_updates_for_addons_page' of https://github…
Crabcyborg Oct 1, 2024
98603e3
Add a check to styler JS if there are no forms to avoid a JS error
Crabcyborg Oct 1, 2024
498ad3b
Try more verbose logging
Crabcyborg Oct 1, 2024
bbef588
Try to add smtp page exception
Crabcyborg Oct 1, 2024
f19aa9f
Merge pull request #2012 from Strategy11/cypress_test_updates_for_add…
Crabcyborg Oct 1, 2024
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
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
},
"plugins": ["react", "jsx-a11y", "sonarjs", "cypress", "no-jquery", "compat"],
"settings": {
"import/resolver": {
"webpack": {
"config": "webpack.config.js"
}
},
"react": {
"pragma": "wp"
}
Expand Down
199 changes: 186 additions & 13 deletions classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,88 @@

class FrmAddonsController {

/**
* @var string
*/
const SCRIPT_HANDLE = 'frm-addons-page';

/**
* @var array
*/
private static $categories = array();

/**
* @var string
*/
private static $request_addon_url;

/**
* @var string
*/
protected static $plugin;

/**
* @since x.x
*/
public static function load_admin_hooks() {
add_action( 'admin_menu', __CLASS__ . '::menu', 100 );
add_filter( 'pre_set_site_transient_update_plugins', __CLASS__ . '::check_update' );

if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) {
self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/';

add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 );
add_filter( 'frm_show_footer_links', '__return_false' );
}
}

/**
* Enqueues the Add-Ons page scripts and styles.
*
* @since x.x
*
* @return void
*/
public static function enqueue_assets() {
$plugin_url = FrmAppHelper::plugin_url();
$version = FrmAppHelper::plugin_version();
$js_dependencies = array(
'wp-i18n',
// This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7.
'wp-hooks',
'formidable_dom',
);

// Enqueue styles that needed.
wp_enqueue_style( 'formidable-admin' );
wp_enqueue_style( 'formidable-grids' );

// Register and enqueue Add-Ons page style.
wp_register_style( self::SCRIPT_HANDLE, $plugin_url . '/css/admin/addons-page.css', array(), $version );
wp_enqueue_style( self::SCRIPT_HANDLE );

// Register and enqueue Add-Ons page script.
wp_register_script( self::SCRIPT_HANDLE, $plugin_url . '/js/addons-page.js', $js_dependencies, $version, true );
wp_localize_script( self::SCRIPT_HANDLE, 'frmAddonsVars', self::get_js_variables() );
wp_enqueue_script( self::SCRIPT_HANDLE );

FrmAppHelper::dequeue_extra_global_scripts();
}

/**
* Get the Add-Ons page JS variables as an array.
*
* @since x.x
*
* @return array
*/
private static function get_js_variables() {
return array(
'proIsIncluded' => FrmAppHelper::pro_is_included(),
'addonRequestURL' => self::$request_addon_url,
);
}

/**
* @return void
*/
Expand All @@ -19,7 +96,7 @@ public static function menu() {
}

$label = __( 'Add-Ons', 'formidable' );
$label = '<span style="color:#1da867">' . $label . '</span>';
$label = '<span style="color:#3FCA89">' . $label . '</span>';

add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );

Expand All @@ -46,11 +123,13 @@ public static function menu() {
*/
public static function list_addons() {
FrmAppHelper::include_svg();
$installed_addons = apply_filters( 'frm_installed_addons', array() );
$license_type = '';

$addons = self::get_api_addons();
$errors = array();
$view_path = FrmAppHelper::plugin_path() . '/classes/views/addons/';
$installed_addons = apply_filters( 'frm_installed_addons', array() );
$addons = self::get_api_addons();
$errors = array();
$license_type = '';
$request_addon_url = self::$request_addon_url;

if ( isset( $addons['error'] ) ) {
$api = new FrmFormApi();
Expand All @@ -61,19 +140,111 @@ public static function list_addons() {

$pro = array(
'pro' => array(
'title' => 'Formidable Forms Pro',
'slug' => 'formidable-pro',
'released' => '2011-02-05',
'docs' => 'knowledgebase/',
'excerpt' => 'Create calculators, surveys, smart forms, and data-driven applications. Build directories, real estate listings, job boards, and much more.',
'title' => 'Formidable Forms Pro',
'slug' => 'formidable-pro',
'released' => '2011-02-05',
'docs' => 'knowledgebase/',
'categories' => array( 'basic', 'plus', 'business', 'elite' ),
'excerpt' => 'Create calculators, surveys, smart forms, and data-driven applications. Build directories, real estate listings, job boards, and much more.',
),
);
$addons = $pro + $addons;
self::prepare_addons( $addons );

$pricing = FrmAppHelper::admin_upgrade_link( 'addons' );

include FrmAppHelper::plugin_path() . '/classes/views/addons/list.php';
self::organize_and_get_categories();
$categories = self::$categories;

include $view_path . 'index.php';
}

/**
* Organize and set categories.
*
* @since x.x
*
* @return void
*/
protected static function organize_and_get_categories() {
unset( self::$categories['strategy11'] );
ksort( self::$categories );

$bottom_categories = array();
$plans = FrmFormsHelper::get_license_types(
array(
'include_all' => false,
'case_lower' => true,
)
);

// Extract the elements to move
foreach ( $plans as $plan ) {
if ( isset( self::$categories[ $plan ] ) ) {
$bottom_categories[ $plan ] = self::$categories[ $plan ];
unset( self::$categories[ $plan ] );
}
}

$special_categories = array();
if ( 'elite' !== self::license_type() ) {
$special_categories['available-addons'] = array(
'name' => __( 'Available', 'formidable' ),
// To be assigned via JavaScript.
'count' => 0,
);
}

$special_categories['active-addons'] = array(
'name' => __( 'Active', 'formidable' ),
// To be assigned via JavaScript.
'count' => 0,
);

$special_categories['all-items'] = array(
'name' => __( 'All Add-Ons', 'formidable' ),
// To be assigned via JavaScript.
'count' => 0,
);

self::$categories = array_merge(
$special_categories,
self::$categories,
$bottom_categories
);
}

/**
* Organize and set categories.
*
* @since x.x
*
* @param array $addon The addon array that will be modified by reference.
* @return void
*/
protected static function set_categories( &$addon ) {
Comment thread
shervElmi marked this conversation as resolved.
if ( ! isset( $addon['categories'] ) ) {
return;
}

$addon['category-slugs'] = array();

foreach ( $addon['categories'] as $category ) {
$category = FrmFormsHelper::convert_legacy_package_names( $category );
$category_slug = sanitize_title( $category );

// Add the slug to the new array.
$addon['category-slugs'][] = $category_slug;

if ( ! isset( self::$categories[ $category_slug ] ) ) {
self::$categories[ $category_slug ] = array(
'name' => $category,
'count' => 0,
);
}

++self::$categories[ $category_slug ]['count'];
}
}

/**
Expand Down Expand Up @@ -618,9 +789,11 @@ protected static function prepare_addons( &$addons ) {
if ( ! isset( $addon['link'] ) ) {
$addon['link'] = 'downloads/' . $slug . '/';
}
self::prepare_addon_link( $addon['link'] );

self::prepare_addon_link( $addon['link'] );
self::set_addon_status( $addon );
self::set_categories( $addon );

$addons[ $id ] = $addon;
}//end foreach
}
Expand Down Expand Up @@ -1441,7 +1614,7 @@ public static function show_conditional_action_button( $atts ) {
*
* @return void
*/
protected static function addon_upgrade_link( $addon, $upgrade_link ) {
public static function addon_upgrade_link( $addon, $upgrade_link ) {
$atts = is_array( $upgrade_link ) ? $upgrade_link : array();
$upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;

Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/FrmFormTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private static function organize_and_set_categories() {

// Filter out certain and redundant categories.
// 'PayPal', 'Stripe', and 'Twilio' are included elsewhere and should be ignored in this context.
$redundant_cats = array_merge( array( 'PayPal', 'Stripe', 'Twilio' ), FrmFormsHelper::ignore_template_categories() );
$redundant_cats = array_merge( array( 'PayPal', 'Stripe', 'Twilio' ), FrmFormsHelper::get_license_types() );
foreach ( $redundant_cats as $redundant_cat ) {
$category_slug = sanitize_title( $redundant_cat );
unset( self::$categories[ $category_slug ] );
Expand Down Expand Up @@ -522,7 +522,7 @@ private static function organize_and_set_categories() {
'count' => 0,
);
}
$special_categories['all-templates'] = array(
$special_categories['all-items'] = array(
'name' => __( 'All Templates', 'formidable' ),
'count' => self::get_template_count(),
);
Expand Down
5 changes: 1 addition & 4 deletions classes/controllers/FrmHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ public static function load_admin_hooks() {
add_action( 'wp_ajax_frm_dismiss_review', 'FrmAppController::dismiss_review' );
add_action( 'current_screen', 'FrmAppController::filter_admin_notices' );

// Addons Controller.
add_action( 'admin_menu', 'FrmAddonsController::menu', 100 );
add_filter( 'pre_set_site_transient_update_plugins', 'FrmAddonsController::check_update' );

// Entries Controller.
add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
Expand Down Expand Up @@ -204,6 +200,7 @@ public static function load_admin_hooks() {
FrmStrpLiteHooksController::load_admin_hooks();
FrmSMTPController::load_hooks();
FrmOnboardingWizardController::load_admin_hooks();
FrmAddonsController::load_admin_hooks();
new FrmPluginSearch();
}

Expand Down
Loading