Skip to content

Commit

Permalink
fix for function qtranxf_plugin_basename to work hopefully everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed Sep 30, 2015
1 parent f2a11d8 commit 7c9ba61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
17 changes: 5 additions & 12 deletions admin/qtx_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ function qtranxf_admin_load()
if(!empty($page_configs['']['filters'])){
qtranxf_add_filters($page_configs['']['filters']);
}
$bnm = qtranxf_plugin_basename();
add_filter( 'plugin_action_links_'.$bnm, 'qtranxf_links', 10, 4);
qtranxf_add_admin_filters();
}
qtranxf_admin_load();
Expand Down Expand Up @@ -694,19 +696,11 @@ function qtranxf_add_language_menu( $wp_admin_bar ){
}
}

function qtranxf_links($links, $file){ // copied from Sociable Plugin
//Static so we don't call plugin_basename on every plugin row.
static $this_plugin;
if (!$this_plugin){
$this_plugin = plugin_basename(QTRANSLATE_FILE);
}
if ($file == $this_plugin){
$settings_link = '<a href="options-general.php?page=qtranslate-x">' . __('Settings', 'qtranslate') . '</a>';
array_unshift( $links, $settings_link ); // before other links
}
function qtranxf_links($links, $file, $plugin_data, $context){
$settings_link = '<a href="options-general.php?page=qtranslate-x">' . __('Settings', 'qtranslate') . '</a>';
array_unshift( $links, $settings_link ); // before other links
return $links;
}
add_filter('plugin_action_links', 'qtranxf_links', 10, 2);

//should be moved to qtx_configuration.php from qtx_admin.php ?
function qtranxf_admin_notices_config() {
Expand Down Expand Up @@ -784,7 +778,6 @@ function qtranxf_add_admin_filters()
add_filter('home_url', 'qtranxf_admin_home_url', 5, 4);
}
}
//qtranxf_add_admin_filters();

add_action('admin_head-nav-menus.php', 'qtranxf_add_nav_menu_metabox');
add_action('admin_menu', 'qtranxf_admin_menu', 999);
Expand Down
4 changes: 2 additions & 2 deletions inc/qtx_dbg.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function qtranxf_dbg_log($msg,$var='novar',$bt=false,$exit=false){
}
if(!empty($h)) $msg = $h.': '.$msg;
if( $var !== 'novar' ){
//$msg .= var_export($var,true);
$msg .= print_r($var,true);
$msg .= var_export($var,true);
//$msg .= print_r($var,true);
}
if($bt){
//$msg .= PHP_EOL.'backtrace:'.PHP_EOL.var_export(debug_backtrace(),true);
Expand Down
7 changes: 3 additions & 4 deletions qtranslate_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ function qtranxf_translate_wp($s) { return __($s); }
function qtranxf_plugin_basename(){
static $s;
if(!$s){
$b = plugin_basename(QTRANSLATE_FILE);
$s = basename(dirname($b)).'/'.basename($b);//Windows trick when folder is linked
$s = plugin_basename(wp_normalize_path(QTRANSLATE_FILE));
}
return $s;
}
Expand All @@ -68,8 +67,8 @@ function qtranxf_plugin_basename(){
function qtranxf_plugin_dirname(){
static $s;
if(!$s){
$b = plugin_basename(QTRANSLATE_FILE);
$s = basename(dirname($b));//Windows trick when folder is linked
$b = qtranxf_plugin_basename();
$s = dirname($b);
}
return $s;
}
Expand Down

0 comments on commit 7c9ba61

Please sign in to comment.