Skip to content

Commit

Permalink
Fix PHP error when polylang plugin activated #960
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Nov 15, 2022
1 parent 3826a12 commit 7a6604d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions classes/Visualizer/Module/Admin.php
Expand Up @@ -768,8 +768,8 @@ function setScreenOptions( $status, $option, $value ) {
*/
private function getDisplayFilters( &$query_args ) {
$query = array();

if ( Visualizer_Module::is_pro() && function_exists( 'icl_get_languages' ) ) {
global $sitepress;
if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) {
$current_lang = icl_get_current_language();
if ( in_array( $current_lang, array( 'all', icl_get_default_language() ), true ) ) {
$query[] = array(
Expand Down Expand Up @@ -1138,16 +1138,15 @@ public static function proFeaturesLocked() {
* @return bool Default false
*/
public function addMultilingualSupport( $chart_id ) {
global $sitepress;
if ( Visualizer_Module::is_pro() ) {
return;
}
if ( function_exists( 'icl_get_languages' ) ) {
if ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) {
$language = icl_get_languages();
$current_lang = icl_get_current_language();
$default_lang = icl_get_default_language();
$post_info = wpml_get_language_information( null, $chart_id );

global $sitepress;
$translations = array();
if ( ! empty( $post_info ) && ( $default_lang === $post_info['language_code'] ) ) {
$trid = $sitepress->get_element_trid( $chart_id, 'post_' . Visualizer_Plugin::CPT_VISUALIZER );
Expand Down
4 changes: 2 additions & 2 deletions classes/Visualizer/Module/Chart.php
Expand Up @@ -461,8 +461,8 @@ public function deleteChart() {
}
}
if ( $success ) {
if ( Visualizer_Module::is_pro() && function_exists( 'icl_get_languages' ) ) {
global $sitepress;
global $sitepress;
if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) {
$trid = $sitepress->get_element_trid( $chart_id, 'post_' . Visualizer_Plugin::CPT_VISUALIZER );
$translations = $sitepress->get_element_translations( $trid );
if ( ! empty( $translations ) ) {
Expand Down
3 changes: 2 additions & 1 deletion classes/Visualizer/Module/Frontend.php
Expand Up @@ -305,7 +305,8 @@ public function renderChart( $atts ) {
$atts
);

if ( Visualizer_Module::is_pro() && function_exists( 'icl_get_languages' ) ) {
global $sitepress;
if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) {
global $sitepress;
$locale = icl_get_current_language();
$locale = strtolower( str_replace( '_', '-', $locale ) );
Expand Down

0 comments on commit 7a6604d

Please sign in to comment.