0

i using a wordpress plugin, i notice that returns a error on

$alias = (string)end(array_keys($settings));

above line .the error is PHP Strict Standards: Only variables should be passed by reference in on wordpress function

i added that function below. anyone know how to solve that error please, becoz admin dashboard of the plugin not loading because of this error.

 /*
            * GET modules lists
            */
            function load_modules ()
            {
                $folder_path = $this->cfg['paths']['plugin_dir_path'] . 'modules/';
                $cfgFileName = 'config.php';

                // static usage, modules menu order
                $menu_order = array();

                foreach(glob($folder_path . '*/' . $cfgFileName) as $module_config ){
                    $module_folder = str_replace($cfgFileName, '', $module_config);

                    // Turn on output buffering
                    ob_start();

                    if( is_file( $module_config ) ) {
                        require_once( $module_config  );
                    }
                    $settings = ob_get_clean(); //copy current buffer contents into $message variable and delete current output buffer

                    if(trim($settings) != "") {
                        $settings = json_decode($settings, true);
                        $alias = (string) end(array_keys($settings));

                        // create the module folder URI
                        // fix for windows server
                        $module_folder = str_replace( DIRECTORY_SEPARATOR, '/',  $module_folder );

                        $__tmpUrlSplit = explode("/", $module_folder);
                        $__tmpUrl = '';
                        $nrChunk = count($__tmpUrlSplit);
                        if($nrChunk > 0) {
                            foreach ($__tmpUrlSplit as $key => $value){
                                if( $key > ( $nrChunk - 4) && trim($value) != ""){
                                    $__tmpUrl .= $value . "/";
                                }
                            }
                        }

                        // get the module status. Check if it's activate or not
                        $status = false;

                        // default activate all core modules
                        if(in_array( $alias, $this->cfg['core-modules'] )) {
                            $status = true;
                        }else{
                            // activate the modules from DB status
                            $db_alias = $this->alias . '_module_' . $alias;

                            if(get_option($db_alias) == 'true'){
                                $status = true;
                            }
                        }

                        // push to modules array
                        $this->cfg['modules'][$alias] = array_merge(array(
                            'folder_path'   => $module_folder,
                            'folder_uri'    => $this->cfg['paths']['plugin_dir_url'] . $__tmpUrl,
                            'db_alias'      => $this->alias . '_' . $alias,
                            'status'        => $status
                        ), $settings );

                        // add to menu order arrayhttp://cc.aa-team.com/wp-plugins/smart-seo-v2/wp-admin/admin-ajax.php?action=pspLoadSection&section=Social_Stats
                        if(!isset($this->cfg['menu_order'][(int)$settings[$alias]['menu']['order']])){
                            $this->cfg['menu_order'][(int)$settings[$alias]['menu']['order']] = $alias;
                        }else{
                            // add the menu to next free key
                            $this->cfg['menu_order'][] = $alias;
                        }

                        // add module to activate modules array
                        if($status == true){
                            $this->cfg['activate_modules'][$alias] = true;
                        }

                        // load the init of current loop module
                        if( $status == true && isset( $settings[$alias]['module_init'] ) ){
                            if( is_file($module_folder . $settings[$alias]['module_init']) ){
                                //if( is_admin() ) {
                                    $current_module = array($alias => $this->cfg['modules'][$alias]); 
                                    require_once( $module_folder . $settings[$alias]['module_init'] );
                                //}
                            }
                        }
                    }
                }

                // order menu_order ascendent
                ksort($this->cfg['menu_order']);
            }
hakre
  • 193,403
  • 52
  • 435
  • 836
Suneth Kalhara
  • 1,211
  • 6
  • 20
  • 40
  • possible duplicate of [Strict Standards: Only variables should be passed by reference](http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) – Lorenz Meyer Jun 21 '14 at 08:31

1 Answers1

2

End rereceives value by reference, but result of function is not variable.

You could rewrite your code.

$array_keys = array_keys($settings);
$alias = (string)end($array_keys);
unset($array_keys);
sectus
  • 15,605
  • 5
  • 55
  • 97