Skip to content

Commit de76663

Browse files
committed
[filters] [pricing-url] Updated the pricing_url filter so that it also updates the pricing/upgrade submenu item's URL.
1 parent 1567a03 commit de76663

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

includes/class-freemius.php

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14674,6 +14674,20 @@ function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false
1467414674
$this->_parent->addon_url( $this->_slug ) :
1467514675
$this->_get_admin_page_url( 'pricing', $params );
1467614676

14677+
return $this->get_pricing_url_with_filter( $url );
14678+
}
14679+
14680+
/**
14681+
* Retrieves the filtered pricing URL.
14682+
*
14683+
* @author Leo Fajardo (@leorw)
14684+
* @since 2.7.4
14685+
*
14686+
* @param string $url
14687+
*
14688+
* @return string
14689+
*/
14690+
private function get_pricing_url_with_filter( $url ) {
1467714691
return $this->apply_filters( 'pricing_url', $url );
1467814692
}
1467914693

@@ -18800,18 +18814,34 @@ private function add_submenu_items() {
1880018814
}
1880118815
}
1880218816

18803-
// Add upgrade/pricing page.
18804-
$this->add_submenu_item(
18805-
$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' ) ),
18806-
array( &$this, '_pricing_page_render' ),
18807-
$this->get_plugin_name() . ' – ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
18808-
'manage_options',
18809-
'pricing',
18810-
'Freemius::_clean_admin_content_section',
18811-
WP_FS__LOWEST_PRIORITY,
18812-
( $add_submenu_items && $show_pricing ),
18813-
$pricing_class
18814-
);
18817+
$custom_pricing_url = $this->get_pricing_url_with_filter( null );
18818+
$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' ) );
18819+
$show_pricing_submenu_item = ( $add_submenu_items && $show_pricing );
18820+
18821+
// Add upgrade/pricing submenu item.
18822+
if ( ! is_null( $custom_pricing_url ) ) {
18823+
$this->add_submenu_link_item(
18824+
$pricing_menu_title,
18825+
$custom_pricing_url,
18826+
'pricing',
18827+
'manage_options',
18828+
WP_FS__LOWEST_PRIORITY,
18829+
$show_pricing_submenu_item,
18830+
$pricing_class
18831+
);
18832+
} else {
18833+
$this->add_submenu_item(
18834+
$pricing_menu_title,
18835+
array( &$this, '_pricing_page_render' ),
18836+
$this->get_plugin_name() . ' – ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
18837+
'manage_options',
18838+
'pricing',
18839+
'Freemius::_clean_admin_content_section',
18840+
WP_FS__LOWEST_PRIORITY,
18841+
$show_pricing_submenu_item,
18842+
$pricing_class
18843+
);
18844+
}
1881518845
}
1881618846
}
1881718847

@@ -19100,14 +19130,16 @@ function add_submenu_item(
1910019130
* @param string $capability
1910119131
* @param int $priority
1910219132
* @param bool $show_submenu
19133+
* @param string $class
1910319134
*/
1910419135
function add_submenu_link_item(
1910519136
$menu_title,
1910619137
$url,
1910719138
$menu_slug = false,
1910819139
$capability = 'read',
1910919140
$priority = WP_FS__DEFAULT_PRIORITY,
19110-
$show_submenu = true
19141+
$show_submenu = true,
19142+
$class = ''
1911119143
) {
1911219144
$this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );
1911319145

@@ -19121,7 +19153,8 @@ function add_submenu_link_item(
1912119153
$menu_slug,
1912219154
$capability,
1912319155
$priority,
19124-
$show_submenu
19156+
$show_submenu,
19157+
$class
1912519158
);
1912619159

1912719160
return;
@@ -19141,6 +19174,7 @@ function add_submenu_link_item(
1914119174
'render_function' => 'fs_dummy',
1914219175
'before_render_function' => '',
1914319176
'show_submenu' => $show_submenu,
19177+
'class' => $class,
1914419178
);
1914519179
}
1914619180

0 commit comments

Comments
 (0)