Plugin Directory

Changeset 3340531


Ignore:
Timestamp:
08/06/2025 05:49:02 PM (8 months ago)
Author:
sflwa
Message:

Fixed duplicate function between SFLWA plugins

Location:
page-post-converter-for-wpbakery-to-elementor
Files:
16 added
3 edited

Legend:

Unmodified
Added
Removed
  • page-post-converter-for-wpbakery-to-elementor/trunk/page-post-converter-for-wpbakery-to-elementor.php

    r3340514 r3340531  
    33 * Plugin Name: Page/Post Converter for WPBakery to Elementor
    44 * Description: Clones a WordPress page or post and prepares its content for Elementor editing.
    5  * Version: 1.5
     5 * Version: 1.6
    66 * Requires Plugin: elementor
    77 * Author: South Florida Web Advisors
     
    1111 * Requires PHP: 8.0
    1212 * Tested up to: 6.8
    13  * Stable tag: 1.5
     13 * Stable tag: 1.6
    1414 * Text Domain: page-post-converter-for-wpbakery-to-elementor
    1515 */
  • page-post-converter-for-wpbakery-to-elementor/trunk/readme.txt

    r3340514 r3340531  
    44Requires at least: 6.7
    55Tested up to: 6.8
    6 Stable tag: 1.5
     6Stable tag: 1.6
    77Requires PHP: 8.0
    88License: GPLv2 or later 
     
    4141## Change Log
    4242
     432025-08-06 v1.6
     44* Fixed function name
     45
    43462025-08-06 v1.5
    4447* Fixed function name
  • page-post-converter-for-wpbakery-to-elementor/trunk/sflwa-notice-handler.php

    r3340514 r3340531  
    1919// IMPORTANT: This line should ideally be in your main plugin file,
    2020// but included here for a self-contained example.
    21 if ( ! defined( 'SFLWA_PLUGIN_NAME' ) ) {
    22     define( 'SFLWA_PLUGIN_NAME', 'Page/Post Converter for WPBakery to Elementor' ); // <--- IMPORTANT: Change this for each plugin!
     21if ( ! defined( 'WPB2E_SFLWA_PLUGIN_NAME' ) ) {
     22    define( 'WPB2E_SFLWA_PLUGIN_NAME', 'Page/Post Converter for WPBakery to Elementor' ); // <--- IMPORTANT: Change this for each plugin!
    2323}
    2424
    2525// Register the custom admin notice to be displayed.
    2626// This hook ensures the notice is checked and potentially displayed on every admin page load.
    27 add_action( 'admin_init', 'sflwa_register_admin_notice_wpb2e' );
     27add_action( 'admin_init', 'wpb2e_sflwa_register_admin_notice' );
    2828
    2929/**
     
    3333 * If the transient doesn't exist, it means the notice should be displayed.
    3434 */
    35 function sflwa_register_admin_notice_wpb2e() {
     35function wpb2e_sflwa_register_admin_notice() {
    3636    // Construct a unique transient name based on the plugin name.
    3737    // sanitize_title() ensures the name is safe for a transient key.
    38     $transient_name = 'sflwa_notice_dismissed_' . sanitize_title( SFLWA_PLUGIN_NAME );
     38    $transient_name = 'wpb2e_sflwa_notice_dismissed_' . sanitize_title( WPB2E_SFLWA_PLUGIN_NAME );
    3939
    4040    // Check if the transient exists. If not, add the action to display the notice.
    4141    if ( ! get_transient( $transient_name ) ) {
    42         add_action( 'admin_notices', 'sflwa_display_admin_notice' );
     42        add_action( 'admin_notices', 'wpb2e_sflwa_display_admin_notice' );
    4343    }
    4444}
     
    4848 *
    4949 * This function is hooked into 'admin_notices' and calls the reusable
    50  * `sflwa_display_notice_handler` function, passing in the current plugin's name
     50 * `wpb2e_sflwa_display_notice_handler` function, passing in the current plugin's name
    5151 * and the AJAX URL needed for the JavaScript.
    5252 */
    53 function sflwa_display_admin_notice() {
     53function wpb2e_sflwa_display_admin_notice() {
    5454    // Ensure the current user has permission to see admin notices (e.g., administrator).
    5555    if ( ! current_user_can( 'manage_options' ) ) {
     
    5858
    5959    // Call the shared handler function, passing the plugin name and WordPress AJAX URL.
    60     sflwa_display_notice_handler( SFLWA_PLUGIN_NAME, admin_url( 'admin-ajax.php' ) );
     60    wpb2e_sflwa_display_notice_handler( WPB2E_SFLWA_PLUGIN_NAME, admin_url( 'admin-ajax.php' ) );
    6161}
    6262
     
    6767 * @param string $ajax_url    The URL for the WordPress AJAX endpoint.
    6868 */
    69 function sflwa_display_notice_handler( $plugin_name, $ajax_url ) {
     69function wpb2e_sflwa_display_notice_handler( $plugin_name, $ajax_url ) {
    7070    // Enqueue jQuery if it's not already enqueued (WordPress usually does this in admin).
    7171    // This ensures our inline script can use jQuery.
     
    107107                // Perform AJAX request to submit plugin info.
    108108                $.post('<?php echo esc_url( $ajax_url ); ?>', {
    109                     action: 'sflwa_submit_plugin_info', // WordPress AJAX action hook.
     109                    action: 'wpb2e_sflwa_submit_plugin_info', // WordPress AJAX action hook.
    110110                    plugin_name: notice.data('plugin-name'), // Get plugin name from data attribute.
    111111                    website_url: '<?php echo esc_url( get_home_url() ); ?>', // Get current website URL.
    112                     _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'sflwa_submit_nonce' ) ); ?>' // Security nonce.
     112                    _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpb2e_sflwa_submit_nonce' ) ); ?>' // Security nonce.
    113113                }, function(response) {
    114114                    // Hide spinner after response.
     
    148148                // Perform AJAX request to dismiss the notice permanently.
    149149                $.post('<?php echo esc_url( $ajax_url ); ?>', {
    150                     action: 'sflwa_dismiss_admin_notice', // WordPress AJAX action hook.
     150                    action: 'wpb2e_sflwa_dismiss_admin_notice', // WordPress AJAX action hook.
    151151                    plugin_name: notice.data('plugin-name'), // Get plugin name from data attribute.
    152                     _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'sflwa_dismiss_nonce' ) ); ?>' // Security nonce.
     152                    _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpb2e_sflwa_dismiss_nonce' ) ); ?>' // Security nonce.
    153153                }, function(response) {
    154154                    if (response.success) {
     
    175175                var notice = $(this).closest('.sflwa-admin-notice');
    176176                $.post('<?php echo esc_url( $ajax_url ); ?>', {
    177                     action: 'sflwa_dismiss_admin_notice', // WordPress AJAX action hook.
     177                    action: 'wpb2e_sflwa_dismiss_admin_notice', // WordPress AJAX action hook.
    178178                    plugin_name: notice.data('plugin-name'), // Get plugin name from data attribute.
    179                     _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'sflwa_dismiss_nonce' ) ); ?>' // Security nonce.
     179                    _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpb2e_sflwa_dismiss_nonce' ) ); ?>' // Security nonce.
    180180                }, function(response) {
    181181                    // No specific UI update needed here as the notice is already hidden by WordPress.
     
    193193 * AJAX callback to handle the Gravity Forms submission via a custom proxy endpoint.
    194194 *
    195  * This function is hooked to 'wp_ajax_sflwa_submit_plugin_info'.
     195 * This function is hooked to 'wp_ajax_wpb2e_sflwa_submit_plugin_info'.
    196196 * It receives the plugin name and website URL, and submits them to a custom
    197197 * REST API endpoint on southfloridawebadvisors.com.
    198198 */
    199 add_action( 'wp_ajax_sflwa_submit_plugin_info', 'sflwa_submit_plugin_info_callback' );
    200 function sflwa_submit_plugin_info_callback() {
     199add_action( 'wp_ajax_wpb2e_sflwa_submit_plugin_info', 'wpb2e_sflwa_submit_plugin_info_callback' );
     200function wpb2e_sflwa_submit_plugin_info_callback() {
    201201    // Verify nonce for security.
    202     check_ajax_referer( 'sflwa_submit_nonce', '_ajax_nonce' );
     202    check_ajax_referer( 'wpb2e_sflwa_submit_nonce', '_ajax_nonce' );
    203203
    204204    // Sanitize and retrieve data from the AJAX request.
     
    272272 * AJAX callback to permanently dismiss the admin notice.
    273273 *
    274  * This function is hooked to 'wp_ajax_sflwa_dismiss_admin_notice'.
     274 * This function is hooked to 'wp_ajax_wpb2e_sflwa_dismiss_admin_notice'.
    275275 * It sets a transient to prevent the notice from showing again for this plugin.
    276276 */
    277 add_action( 'wp_ajax_sflwa_dismiss_admin_notice', 'sflwa_dismiss_admin_notice_callback' );
    278 function sflwa_dismiss_admin_notice_callback() {
     277add_action( 'wp_ajax_wpb2e_sflwa_dismiss_admin_notice', 'wpb2e_sflwa_dismiss_admin_notice_callback' );
     278function wpb2e_sflwa_dismiss_admin_notice_callback() {
    279279    // Verify nonce for security.
    280     check_ajax_referer( 'sflwa_dismiss_nonce', '_ajax_nonce' );
     280    check_ajax_referer( 'wpb2e_sflwa_dismiss_nonce', '_ajax_nonce' );
    281281
    282282    // Sanitize and retrieve the plugin name from the AJAX request.
     
    284284
    285285    // Construct the unique transient name.
    286     $transient_name = 'sflwa_notice_dismissed_' . sanitize_title( $plugin_name );
     286    $transient_name = 'wpb2e_sflwa_notice_dismissed_' . sanitize_title( $plugin_name );
    287287
    288288    // Set a transient that never expires (0 seconds lifetime) to permanently hide the notice.
Note: See TracChangeset for help on using the changeset viewer.