Plugin Directory

Changeset 3238736


Ignore:
Timestamp:
02/11/2025 05:23:36 PM (14 months ago)
Author:
wecantrack
Message:

Release 3.1.0

Location:
affiliate-links
Files:
94 added
10 edited

Legend:

Unmodified
Added
Removed
  • affiliate-links/trunk/admin/class-affiliate-links-metabox.php

    r3234074 r3238736  
    115115    public function hide_yoast_columns( $columns ) {
    116116
     117        if ( ! current_user_can( 'manage_options' ) ) {
     118            return $columns;
     119        }
     120
    117121        unset( $columns['wpseo-score'] );
    118122        unset( $columns['wpseo-title'] );
  • affiliate-links/trunk/admin/class-affiliate-links-settings.php

    r3234074 r3238736  
    341341    public function flush_rules() {
    342342
    343         if ( isset( $_GET['settings-updated'] ) ) {
    344             flush_rewrite_rules();
    345         }
     343        if ( current_user_can( 'manage_options' ) && isset( $_GET['settings-updated'] ) ) {
     344            flush_rewrite_rules();
     345        }
    346346
    347347    }
  • affiliate-links/trunk/includes/class-affiliate-links.php

    r3150755 r3238736  
    44    die();
    55}
     6
     7// Include pluggable.php to ensure wp_get_current_user() is available
     8if ( ! function_exists( 'wp_get_current_user' ) ) {
     9    require_once ABSPATH . 'wp-includes/pluggable.php';
     10}
     11
    612/**
    713 * The Affiliate Links Core Plugin Class.
     
    3137        new Affiliate_Links_Settings();
    3238
    33         if ( is_admin() ) {
     39        if ( current_user_can( 'manage_options' ) ) {
    3440            require_once AFFILIATE_LINKS_PLUGIN_DIR . 'admin/class-affiliate-links-metabox.php';
    3541            require_once AFFILIATE_LINKS_PLUGIN_DIR . 'admin/class-affiliate-links-buttons.php';
  • affiliate-links/trunk/pro/class-affiliate-links-pro-import-export.php

    r3150755 r3238736  
    1616        add_action( 'init', array( $this, 'maybe_export' ) );
    1717        add_action( 'init', array( $this, 'maybe_import' ) );
    18         if ( is_admin() ) {
     18        if ( current_user_can( 'manage_options' ) ) {
    1919            add_action( 'admin_menu', array( $this, 'add_menu' ) );
    2020        }
     
    3232
    3333    public function maybe_import() {
    34         if ( isset( $_POST[ 'file_nonce' ] ) && isset( $_FILES[ 'file' ] ) ) {
     34        if ( current_user_can( 'manage_options' ) && isset( $_POST['file_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['file_nonce'] ) ), 'import' ) && isset( $_FILES['file'] ) ) {
    3535            $this->import();
    3636        }
    3737    }
     38
    3839    public function maybe_export() {
    39         if ( isset( $_POST[ 'export_nonce' ] ) ) {
     40        if ( current_user_can( 'manage_options' ) && isset( $_POST['export_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['export_nonce'] ) ), 'export' ) ) {
    4041            $this->export();
    4142        }
  • affiliate-links/trunk/pro/class-affiliate-links-pro-metabox.php

    r3150755 r3238736  
    126126
    127127
     128    /**
     129     * Retrieve the browser links data stored in post meta.
     130     * The data is stored as JSON, so we decode it safely here.
     131     *
     132     * @param string|int $id Optional post ID.
     133     *
     134     * @return array Decoded link data or empty array.
     135     */
    128136    public function get_browser_links( $id = '' ) {
    129137        global $post;
    130138        $post_id = $id ? $id : $post->ID;
    131         $data    = get_post_meta( $post_id, $this->browser_link_meta_key );
    132         if ( count( $data ) ) {
    133             $data = maybe_unserialize( current( $data ) );
     139
     140        // Retrieve raw JSON from post meta
     141        $data = get_post_meta( $post_id, $this->browser_link_meta_key, true );
     142
     143        if ( empty( $data ) ) {
     144            return array();
    134145        }
    135146
    136         return $data;
     147        // Decode JSON
     148        $decoded = json_decode( $data, true );
     149
     150        if ( json_last_error() === JSON_ERROR_NONE && is_array( $decoded ) ) {
     151            return $decoded;
     152        }
     153
     154        return array(); // Return empty if JSON is invalid
    137155    }
    138156
  • affiliate-links/trunk/pro/class-affiliate-links-pro-replacer.php

    r3150755 r3238736  
    55}
    66include_once AFFILIATE_LINKS_PRO_PLUGIN_DIR . '/' . 'class-affiliate-links-pro-base.php';
     7
     8// Include pluggable.php to ensure wp_get_current_user() is available
     9if ( ! function_exists( 'wp_get_current_user' ) ) {
     10    require_once ABSPATH . 'wp-includes/pluggable.php';
     11}
    712
    813class Affiliate_Links_Pro_Replacer extends Affiliate_Links_Pro_Base {
     
    1520        parent::__construct();
    1621
    17         if ( is_admin() ) {
     22        if ( current_user_can( 'manage_options' ) ) {
    1823            add_action( 'admin_menu', array( $this, 'add_menu' ) );
    1924        }
     
    3237
    3338    public function controller() {
    34 
    35         if ( isset( $_POST['replace_links_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['replace_links_nonce'] ) ), 'replace_links' ) ) {
     39        if ( current_user_can( 'manage_options' ) && isset( $_POST['replace_links_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['replace_links_nonce'] ) ), 'replace_links' ) ) {
    3640            $this->current_link        = isset( $_POST['current-link'] ) ? esc_url_raw( $_POST['current-link'] ) : '';
    3741            $this->new_link            = isset( $_POST['new-link'] ) ? esc_url_raw( $_POST['new-link'] ) : '';
     
    4145        $this->render_view( $this->template );
    4246    }
    43 
    4447
    4548    public function replace_link( $current_link, $new_link ) {
  • affiliate-links/trunk/pro/class-affiliate-links-pro-stats.php

    r3150755 r3238736  
    44    die();
    55}
     6
     7// Include pluggable.php to ensure wp_get_current_user() is available
     8if ( ! function_exists( 'wp_get_current_user' ) ) {
     9    require_once ABSPATH . 'wp-includes/pluggable.php';
     10}
     11
    612include_once AFFILIATE_LINKS_PRO_PLUGIN_DIR . '/' . 'class-affiliate-links-pro-base.php';
    713
     
    3137        ) );
    3238
    33         if ( is_admin() ) {
     39        if ( current_user_can( 'manage_options' ) ) {
    3440            add_action( 'admin_menu', array( $this, 'add_menu' ) );
    3541            add_action( 'current_screen', array( $this, 'is_screen' ) );
  • affiliate-links/trunk/pro/class-affiliate-links-pro.php

    r3150755 r3238736  
    7878            'ajax_url' => admin_url( 'admin-ajax.php' ),
    7979            'action'   => 'af_link_additional_settings',
     80            'security' => wp_create_nonce( 'af_link_additional_settings' ),
    8081        ) );
    8182
     
    8687
    8788    public function get_additional_settings() {
    88         if ( isset( $_REQUEST[ 'name' ] ) && FALSE === empty( $_REQUEST[ 'name' ] ) ) {
    89             foreach ( $this->custom_target_url_metabox->get_custom_target_url_values( $_REQUEST[ 'name' ] ) as $value => $label ) {
     89        if ( isset( $_REQUEST['name'] ) && ! empty( $_REQUEST['name'] ) && check_ajax_referer( 'af_link_additional_settings', 'security' ) ) {
     90            foreach ( $this->custom_target_url_metabox->get_custom_target_url_values( sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) ) as $value => $label ) {
    9091                ?>
    9192                <option value="<?php echo esc_attr( $value ) ?>"><?php echo esc_html( $label ) ?></option>
  • affiliate-links/trunk/pro/js/admin-af-links-pro.js

    r3150755 r3238736  
    2929            var data = {
    3030                'action': aLinkTargetUrl.action,
    31                 'name': $(this).find('option:selected').val()
     31                'name': $(this).find('option:selected').val(),
     32                'security': aLinkTargetUrl.security,
    3233            };
    3334            $.post(aLinkTargetUrl.ajax_url, data, function (response) {
  • affiliate-links/trunk/pro/views/html-additional-settings.php

    r3150755 r3238736  
    144144                    var data = {
    145145                        'action': aLinkTargetUrl.action,
    146                         'name': $(this).find('option:selected').val()
     146                        'name': $(this).find('option:selected').val(),
     147                        'security': aLinkTargetUrl.security,
    147148                    };
    148149                    $.post(aLinkTargetUrl.ajax_url, data, function (response) {
Note: See TracChangeset for help on using the changeset viewer.