: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
private function deserve_notice( $notice ) {
$notices = $this->get_user_notices();
if( $notice === false ) {
if( empty( $notices ) ) {
if( isset( $notices[ $this->notice_id ] ) && isset( $notices[ $this->notice_id ][ $this->plugin_name ] ) ) {
if( in_array( $notice, $notices[ $this->notice_id ][ $this->plugin_name ] ) ) {
* This is the main methods for generate the notice.
public function admin_notices(){
$current_notice = current( $this->next_notice() );
if( get_user_meta( get_current_user_id(), $this->plugin_name . '_' . $current_notice, true ) ) {
if( $current_notice == 'opt_in' ) {
do_action( $this->do_notice_action );
do_action( 'wpdeveloper_before_notice_for_' . $this->plugin_name );
do_action( $this->do_notice_action );
do_action( 'wpdeveloper_after_notice_for_' . $this->plugin_name );
* This method is responsible for all dismissible links generation.
* @param string $links_for
public function dismissible_notice( $links_for = '' ){
if( empty( $links_for ) ) {
$links = isset( $this->data['links'][ $links_for ] ) ? $this->data['links'][ $links_for ] : false;
$output = '<ul class="wpdeveloper-notice-link">';
foreach( $links as $key => $link_value ) {
if( ! empty( $link_value['label'] ) ) {
if( isset( $link_value['link'] ) ) {
$link = $link_value['link'];
$target = isset( $link_value['target'] ) ? 'target="'. $link_value['target'] .'"' : '';
if( isset( $link_value['data_args'] ) && is_array( $link_value['data_args'] ) ) {
foreach( $link_value['data_args'] as $key => $args_value ) {
$data_args[ $key ] = $args_value;
$data_args[ 'plugin' ] = $this->plugin_name;
$normal_link = add_query_arg( $data_args, $link );
$link = wp_nonce_url( $normal_link, 'wpdeveloper-nonce' );
if( isset( $link_value['link_class'] ) ) {
$class = 'class="' . implode( ' ', $link_value['link_class'] ) . '"';
$output .= '<a '. $class .' href="'. esc_url( $link ) .'" '. $target .'>';
if( isset( $link_value['icon_class'] ) ) {
$output .= '<span class="'. $link_value['icon_class'] .'"></span>';
if( isset( $link_value['icon_img'] ) ) {
$output .= '<img src="'. esc_url($link_value['icon_img']) .'" />';
$output .= $link_value['label'];
if( isset( $link_value['link'] ) ) {
* First Installation Track
public function first_install_track( $args = array() ){
if( ! current_user_can( 'manage_options' ) ) {
'time' => $this->timestamp,
'version' => $this->version,
$options_data = $this->get_options_data();
$args = wp_parse_args( $args, $this->get_args() );
if( ! isset( $options_data[ $this->plugin_name ] )
|| ( isset( $options_data[ $this->plugin_name ]['version'] ) && version_compare( $options_data[ $this->plugin_name ]['version'], $this->version, '!=' ) ) ) {
$this->update_options_data( $args );
* First Installation Deactive Track
public function first_install_end(){
$options_data = $this->get_options_data();
if( isset( $options_data[ $this->plugin_name ] ) ) {
unset( $options_data[ $this->plugin_name ] );
$this->update_options_data( $options_data, true );
* Get all options from database!
protected function get_options_data( $key = ''){
$options_data = get_option( 'wpdeveloper_plugins_data' );
if( isset( $options_data[ $this->plugin_name ][ $key ] ) ) {
return $options_data[ $this->plugin_name ][ $key ];
* This will update the options table for plugins.
protected function update_options_data( $args = array(), $update = false ){
$options_data = $this->get_options_data();
$options_data[ $this->plugin_name ] = $args;
update_option( 'wpdeveloper_plugins_data', $options_data );
* Set properties data, for some selected properties.
public function __set( $name, $value ){
if( in_array( $name, $this->properties ) ) {
$this->data[ $name ] = $value;
* Invoked when some selected methods are called
public function __call( $name, $values ){
if( in_array( $name, $this->methods ) ) {
$this->data[ $name ][ $values[0] ] = $values[1];
* Get all option arguments.
private function get_args( $key = '' ){
return $this->options_args;
if( isset( $this->options_args[ $key ] ) ) {
return $this->options_args[ $key ];
* Resetting data on update.
private function set_args_on_update(){
$args = $this->get_args();
$options_data = $this->get_options_data();
$set_data = $options_data[ $this->plugin_name ];
$args = wp_parse_args( $set_data, $args );
$this->update_options_data( $args );
* When upgrade is complete. it will fired.
* @param WP_Upgrader $upgrader_object
public function upgrade_completed( $upgrader_object, $options ) {
// If an update has taken place and the updated type is plugins and the plugins element exists
if( isset( $options['action'] ) && $options['action'] == 'update' && $options['type'] == 'plugin' ) {
if( ! isset( $options['plugin'] ) && isset( $options['plugins'] ) ) {
foreach( $options['plugins'] as $plugin ) {
if( $plugin == $this->plugin_name ) {
$this->set_args_on_update();
if( isset( $options['plugin'] ) && $options['plugin'] == $this->plugin_name ) {
$this->set_args_on_update();
* This function is responsible for get_user_notices
private function get_user_notices() {
$notices = get_user_meta( get_current_user_id(), self::ADMIN_UPDATE_NOTICE_KEY, true );
return ! $notices ? array() : $notices;
* This function is responsible for update meta information.
private function update( $notice ){
$options_data = $this->get_options_data();
$user_notices = $this->get_user_notices();
$user_notices[ $this->notice_id ][ $this->plugin_name ][] = $notice;
// Remove the upsale from notice_will_show field in options DB.
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
// Set users meta, not to show again current_version notice.
update_user_meta( get_current_user_id(), self::ADMIN_UPDATE_NOTICE_KEY, $user_notices);
public function notice_dissmiss(){
if( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wpdeveloper_notice_dissmiss' ) ) {
if( ! isset( $_POST['action'] ) || ( $_POST['action'] !== 'wpdeveloper_notice_dissmiss_for_' . $this->plugin_name ) ) {
$dismiss = isset( $_POST['dismiss'] ) ? $_POST['dismiss'] : false;
$notice = isset( $_POST['notice'] ) ? $_POST['notice'] : false;
$this->update( $notice );
* This function is responsible for do action when
* the dismiss button clicked in upsale notice.
public function upsale_notice_dissmiss(){
if( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wpdeveloper_upsale_notice_dissmiss' ) ) {
if( ! isset( $_POST['action'] ) || ( $_POST['action'] !== 'wpdeveloper_upsale_notice_dissmiss_for_' . $this->plugin_name ) ) {
$dismiss = isset( $_POST['dismiss'] ) ? $_POST['dismiss'] : false;
$this->update( 'upsale' );
public function dismiss_button_scripts(){
<script type="text/javascript">
jQuery(document).ready( function($) {
if( $('.notice').length > 0 ) {
$('.notice').on('click', 'button.notice-dismiss', function (e) {
url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
action: 'wpdeveloper_notice_dissmiss_for_<?php echo $this->plugin_name; ?>',
_wpnonce: '<?php echo wp_create_nonce('wpdeveloper_notice_dissmiss'); ?>',
notice: $(this).parents('.notice').data('notice'),
success: function(response) {
console.log('Successfully saved!');
console.log('Something went wrong!');
console.log('Its Complete.');
* When install button is clicked, it will do its own things.
* also for dismiss button JS.
public function upsale_button_script(){
$upsale_args = $this->get_upsale_args();
$plugin_slug = ( isset( $upsale_args['slug'] ) ) ? $upsale_args['slug'] : '';
$plugin_file = ( isset( $upsale_args['file'] ) ) ? $upsale_args['file'] : '';
$page_slug = ( isset( $upsale_args['page_slug'] ) ) ? $upsale_args['page_slug'] : '';
<script type="text/javascript">
jQuery(document).ready( function($) {
<?php if( ! empty( $plugin_slug ) && ! empty( $plugin_file ) ) : ?>
$('#plugin-install-core-<?php echo $this->plugin_name; ?>').on('click', function (e) {
self.addClass('install-now updating-message');
self.text('<?php echo esc_js( 'Installing...' ); ?>');
url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
action: 'wpdeveloper_upsale_core_install_<?php echo $this->plugin_name; ?>',
_wpnonce: '<?php echo wp_create_nonce('wpdeveloper_upsale_core_install_' . $this->plugin_name); ?>',
slug : '<?php echo $plugin_slug; ?>',
file : '<?php echo $plugin_file; ?>'
success: function(response) {
self.text('<?php echo esc_js( 'Installed' ); ?>');
<?php if( ! empty( $page_slug ) ) : ?>
window.location.href = '<?php echo admin_url( "admin.php?page={$page_slug}" ); ?>';
self.removeClass('install-now updating-message');
self.attr('disabled', 'disabled');
self.removeClass('install-now updating-message');
$('.wpdeveloper-upsale-notice').on('click', 'button.notice-dismiss', function (e) {
url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
action: 'wpdeveloper_upsale_notice_dissmiss_for_<?php echo $this->plugin_name; ?>',
_wpnonce: '<?php echo wp_create_nonce('wpdeveloper_upsale_notice_dissmiss'); ?>',
success: function(response) {
console.log('Successfully saved!');
console.log('Something went wrong!');
console.log('Its Complete.');