Skip to content

Commit

Permalink
[filters] [pricing-url] Updated the pricing_url filter so that it als…
Browse files Browse the repository at this point in the history
…o updates the pricing/upgrade submenu item's URL.
  • Loading branch information
fajardoleo committed Jul 23, 2024
1 parent 1567a03 commit de76663
Showing 1 changed file with 48 additions and 14 deletions.
62 changes: 48 additions & 14 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -14674,6 +14674,20 @@ function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false
$this->_parent->addon_url( $this->_slug ) :
$this->_get_admin_page_url( 'pricing', $params );

return $this->get_pricing_url_with_filter( $url );
}

/**
* Retrieves the filtered pricing URL.
*
* @author Leo Fajardo (@leorw)
* @since 2.7.4
*
* @param string $url
*
* @return string
*/
private function get_pricing_url_with_filter( $url ) {
return $this->apply_filters( 'pricing_url', $url );
}

Expand Down Expand Up @@ -18800,18 +18814,34 @@ private function add_submenu_items() {
}
}

// Add upgrade/pricing page.
$this->add_submenu_item(
$pricing_cta_text . '  ' . ( is_rtl() ? $this->get_text_x_inline( '←', 'ASCII arrow left icon', 'symbol_arrow-left' ) : $this->get_text_x_inline( '➤', 'ASCII arrow right icon', 'symbol_arrow-right' ) ),
array( &$this, '_pricing_page_render' ),
$this->get_plugin_name() . ' – ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
'manage_options',
'pricing',
'Freemius::_clean_admin_content_section',
WP_FS__LOWEST_PRIORITY,
( $add_submenu_items && $show_pricing ),
$pricing_class
);
$custom_pricing_url = $this->get_pricing_url_with_filter( null );
$pricing_menu_title = $pricing_cta_text . '  ' . ( is_rtl() ? $this->get_text_x_inline( '←', 'ASCII arrow left icon', 'symbol_arrow-left' ) : $this->get_text_x_inline( '➤', 'ASCII arrow right icon', 'symbol_arrow-right' ) );
$show_pricing_submenu_item = ( $add_submenu_items && $show_pricing );

// Add upgrade/pricing submenu item.
if ( ! is_null( $custom_pricing_url ) ) {
$this->add_submenu_link_item(
$pricing_menu_title,
$custom_pricing_url,
'pricing',
'manage_options',
WP_FS__LOWEST_PRIORITY,
$show_pricing_submenu_item,
$pricing_class
);
} else {
$this->add_submenu_item(
$pricing_menu_title,
array( &$this, '_pricing_page_render' ),
$this->get_plugin_name() . ' – ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
'manage_options',
'pricing',
'Freemius::_clean_admin_content_section',
WP_FS__LOWEST_PRIORITY,
$show_pricing_submenu_item,
$pricing_class
);
}
}
}

Expand Down Expand Up @@ -19100,14 +19130,16 @@ function add_submenu_item(
* @param string $capability
* @param int $priority
* @param bool $show_submenu
* @param string $class
*/
function add_submenu_link_item(
$menu_title,
$url,
$menu_slug = false,
$capability = 'read',
$priority = WP_FS__DEFAULT_PRIORITY,
$show_submenu = true
$show_submenu = true,
$class = ''
) {
$this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );

Expand All @@ -19121,7 +19153,8 @@ function add_submenu_link_item(
$menu_slug,
$capability,
$priority,
$show_submenu
$show_submenu,
$class
);

return;
Expand All @@ -19141,6 +19174,7 @@ function add_submenu_link_item(
'render_function' => 'fs_dummy',
'before_render_function' => '',
'show_submenu' => $show_submenu,
'class' => $class,
);
}

Expand Down

0 comments on commit de76663

Please sign in to comment.