PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | includes/misc-functions.php +77 -1 4.15.04.16.9 View file →
@@ -692,8 +692,10 @@
692 692 *
693 693 * @param int $donation_id Donation ID.
694 694 *
695 695 * @return bool Whether the receipt is visible or not.
696 +
697 + * @since 4.16.6 Require the give_nl cookie to be a scalar string before using it as a donor lookup token.
696 698 * @since 1.3.2
697 699 */
698 700 function give_can_view_receipt( $donation_id ) {
699 701
@@ -744,9 +746,13 @@
744 746 }
745 747
746 748 // Check whether it is receipt access session?
747 749 $receipt_session = give_get_receipt_session();
748 - $email_access_token = ! empty( $_COOKIE['give_nl'] ) ? give_clean( $_COOKIE['give_nl'] ) : false;
750 + // The give_nl cookie must be a scalar string token; give_clean() does not coerce arrays
751 + // to a string, so require is_string() explicitly before treating it as a token.
752 + $email_access_token = ! empty( $_COOKIE['give_nl'] ) && is_string( $_COOKIE['give_nl'] )
753 + ? give_clean( $_COOKIE['give_nl'] )
754 + : false;
749 755
750 756 if (
751 757 ! empty( $receipt_session ) ||
752 758 (
@@ -1894,8 +1900,78 @@
1894 1900 $data = maybe_unserialize( $GLOBALS['give_addon_activated_by_user'][ $option_name ] );
1895 1901 }
1896 1902
1897 1903 return $data;
1904 +}
1905 +
1906 +/**
1907 + * Store recently activated Give's addons to wp options.
1908 + *
1909 + * @since 4.16.7.1 Moved from includes/admin/plugins.php so the listener is registered on every
1910 + * request, and fall back to the plugin file passed by the `activated_plugin`
1911 + * action so add-ons activated outside of plugins.php (REST, WP-CLI,
1912 + * programmatic `activate_plugin()`, etc.) are recorded too.
1913 + * @since 2.1.0
1914 + *
1915 + * @param string $activated_plugin Plugin file passed by the `activated_plugin` action.
1916 + */
1917 +function give_recently_activated_addons( $activated_plugin = '' ) {
1918 + $plugins = [];
1919 +
1920 + // Check if action is set.
1921 + if ( isset( $_REQUEST['action'] ) ) {
1922 + $plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' );
1923 +
1924 + switch ( $plugin_action ) {
1925 + case 'activate': // Single add-on activation.
1926 + $plugins[] = $_REQUEST['plugin'];
1927 + break;
1928 + case 'activate-selected': // If multiple add-ons activated.
1929 + $plugins = $_REQUEST['checked'];
1930 + break;
1931 + }
1932 + }
1933 +
1934 + /**
1935 + * Activations that do not come from the plugins.php form (Harbor's feature manager,
1936 + * WP-CLI, plugin dependencies, any direct `activate_plugin()` call) have no matching
1937 + * request parameters, so use the plugin file the action itself provides.
1938 + */
1939 + if ( empty( $plugins ) && ! empty( $activated_plugin ) ) {
1940 + $plugins[] = $activated_plugin;
1941 + }
1942 +
1943 + if ( ! empty( $plugins ) ) {
1944 +
1945 + $give_addons = give_get_recently_activated_addons();
1946 +
1947 + foreach ( $plugins as $plugin ) {
1948 + // Get plugins which has 'Give-' as prefix.
1949 + if ( stripos( $plugin, 'Give-' ) !== false ) {
1950 + $give_addons[] = $plugin;
1951 + }
1952 + }
1953 +
1954 + if ( ! empty( $give_addons ) ) {
1955 + // Update the Give's activated add-ons.
1956 + update_option( 'give_recently_activated_addons', $give_addons, false );
1957 + }
1958 + }
1959 +}
1960 +
1961 +// Add add-on plugins to wp option table.
1962 +add_action( 'activated_plugin', 'give_recently_activated_addons', 10 );
1963 +
1964 +/**
1965 + * Get list of add-on last activated.
1966 + *
1967 + * @since 4.16.7.1 Moved from includes/admin/plugins.php.
1968 + * @since 2.1.3
1969 + *
1970 + * @return mixed|array list of recently activated add-on
1971 + */
1972 +function give_get_recently_activated_addons() {
1973 + return get_option( 'give_recently_activated_addons', [] );
1898 1974 }
1899 1975
1900 1976 /**
1901 1977 * Get time interval for which nonce is valid