Refactor create_functionHow to add an anonymous function in wordpress hooks by removing create_functionCustom post type single (permalink) throws a 404 errorCustom Registration username_exists / email_exists

What does it mean to "control target player"?

When two first person POV characters meet

Who are the remaining King/Queenslayers?

Unusual mail headers, evidence of an attempted attack. Have I been pwned?

Silly doubt about tidal effects and Einstein Field Equations

What exactly is the 'online' in OLAP and OLTP?

How to find the last non zero element in every column throughout dataframe?

How many children?

Dates on degrees don’t make sense – will people care?

Find the C-factor of a vote

What was the Shuttle Carrier Aircraft escape tunnel?

Does having had a visa for a country mean I used to be a citizen/national of that country?

Prime sieve in Python

Are all instances of trolls turning to stone ultimately references back to Tolkien?

Why is prior to creation called holy?

How to remove this component from PCB

Is a single radon-daughter atom in air a solid?

What size of powerbank will I need to power a phone and DSLR for 2 weeks?

What did River say when she woke from her proto-comatose state?

Non-flat partitions of a set

Suggested order for Amazon Prime Doctor Who series

What is the origin of Scooby-Doo's name?

Is this proposal by U.S. presidential candidate Pete Buttigieg to change the composition of the Supreme Court constitutional?

Is it damaging to turn off a small fridge for two days every week?



Refactor create_function


How to add an anonymous function in wordpress hooks by removing create_functionCustom post type single (permalink) throws a 404 errorCustom Registration username_exists / email_exists






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction?



 function _options_page()
if($this->args['page_type'] == 'submenu')else
$this->page = add_theme_page(
$this->args['page_title'],
$this->args['menu_title'],
$this->args['page_cap'],
$this->args['page_slug'],
array(&$this, '_options_page_html'),
$this->args['menu_icon'],
$this->args['page_position']
);

if(true === $this->args['allow_sub_menu'])

//this is needed to remove the top level menu item from showing in the submenu
add_theme_page($this->args['page_slug'],$this->args['page_title'],'',$this->args['page_cap'],$this->args['page_slug'],create_function( '$a', "return null;" ));


foreach($this->sections as $k => $section)

add_theme_page(
$this->args['page_slug'],
$section['title'],
$section['title'],
$this->args['page_cap'],
$this->args['page_slug'].'&tab='.$k,
create_function( '$a', "return null;" )
);



if(true === $this->args['show_import_export'])

add_theme_page(
$this->args['page_slug'],
__('Import / Export', 'nhp-opts'),
__('Import / Export', 'nhp-opts'),
$this->args['page_cap'],
$this->args['page_slug'].'&tab=import_export_default',
create_function( '$a', "return null;" )
);

//if

foreach($this->extra_tabs as $k => $tab)

add_theme_page(
$this->args['page_slug'],
$tab['title'],
$tab['title'],
$this->args['page_cap'],
$this->args['page_slug'].'&tab='.$k,
create_function( '$a', "return null;" )
);


if(true === $this->args['dev_mode'])

add_theme_page(
$this->args['page_slug'],
__('Dev Mode Info', 'nhp-opts'),
__('Dev Mode Info', 'nhp-opts'),
$this->args['page_cap'],
$this->args['page_slug'].'&tab=dev_mode_default',
create_function( '$a', "return null;" )
);

//if
//if


//else
add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
add_action('load-'.$this->page, array(&$this, '_load_page'));
//function









share|improve this question




























    1















    I'm getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction?



     function _options_page()
    if($this->args['page_type'] == 'submenu')else
    $this->page = add_theme_page(
    $this->args['page_title'],
    $this->args['menu_title'],
    $this->args['page_cap'],
    $this->args['page_slug'],
    array(&$this, '_options_page_html'),
    $this->args['menu_icon'],
    $this->args['page_position']
    );

    if(true === $this->args['allow_sub_menu'])

    //this is needed to remove the top level menu item from showing in the submenu
    add_theme_page($this->args['page_slug'],$this->args['page_title'],'',$this->args['page_cap'],$this->args['page_slug'],create_function( '$a', "return null;" ));


    foreach($this->sections as $k => $section)

    add_theme_page(
    $this->args['page_slug'],
    $section['title'],
    $section['title'],
    $this->args['page_cap'],
    $this->args['page_slug'].'&tab='.$k,
    create_function( '$a', "return null;" )
    );



    if(true === $this->args['show_import_export'])

    add_theme_page(
    $this->args['page_slug'],
    __('Import / Export', 'nhp-opts'),
    __('Import / Export', 'nhp-opts'),
    $this->args['page_cap'],
    $this->args['page_slug'].'&tab=import_export_default',
    create_function( '$a', "return null;" )
    );

    //if

    foreach($this->extra_tabs as $k => $tab)

    add_theme_page(
    $this->args['page_slug'],
    $tab['title'],
    $tab['title'],
    $this->args['page_cap'],
    $this->args['page_slug'].'&tab='.$k,
    create_function( '$a', "return null;" )
    );


    if(true === $this->args['dev_mode'])

    add_theme_page(
    $this->args['page_slug'],
    __('Dev Mode Info', 'nhp-opts'),
    __('Dev Mode Info', 'nhp-opts'),
    $this->args['page_cap'],
    $this->args['page_slug'].'&tab=dev_mode_default',
    create_function( '$a', "return null;" )
    );

    //if
    //if


    //else
    add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
    add_action('load-'.$this->page, array(&$this, '_load_page'));
    //function









    share|improve this question
























      1












      1








      1








      I'm getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction?



       function _options_page()
      if($this->args['page_type'] == 'submenu')else
      $this->page = add_theme_page(
      $this->args['page_title'],
      $this->args['menu_title'],
      $this->args['page_cap'],
      $this->args['page_slug'],
      array(&$this, '_options_page_html'),
      $this->args['menu_icon'],
      $this->args['page_position']
      );

      if(true === $this->args['allow_sub_menu'])

      //this is needed to remove the top level menu item from showing in the submenu
      add_theme_page($this->args['page_slug'],$this->args['page_title'],'',$this->args['page_cap'],$this->args['page_slug'],create_function( '$a', "return null;" ));


      foreach($this->sections as $k => $section)

      add_theme_page(
      $this->args['page_slug'],
      $section['title'],
      $section['title'],
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab='.$k,
      create_function( '$a', "return null;" )
      );



      if(true === $this->args['show_import_export'])

      add_theme_page(
      $this->args['page_slug'],
      __('Import / Export', 'nhp-opts'),
      __('Import / Export', 'nhp-opts'),
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab=import_export_default',
      create_function( '$a', "return null;" )
      );

      //if

      foreach($this->extra_tabs as $k => $tab)

      add_theme_page(
      $this->args['page_slug'],
      $tab['title'],
      $tab['title'],
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab='.$k,
      create_function( '$a', "return null;" )
      );


      if(true === $this->args['dev_mode'])

      add_theme_page(
      $this->args['page_slug'],
      __('Dev Mode Info', 'nhp-opts'),
      __('Dev Mode Info', 'nhp-opts'),
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab=dev_mode_default',
      create_function( '$a', "return null;" )
      );

      //if
      //if


      //else
      add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
      add_action('load-'.$this->page, array(&$this, '_load_page'));
      //function









      share|improve this question














      I'm getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. Would anyone be able to get me pointed in the right direction?



       function _options_page()
      if($this->args['page_type'] == 'submenu')else
      $this->page = add_theme_page(
      $this->args['page_title'],
      $this->args['menu_title'],
      $this->args['page_cap'],
      $this->args['page_slug'],
      array(&$this, '_options_page_html'),
      $this->args['menu_icon'],
      $this->args['page_position']
      );

      if(true === $this->args['allow_sub_menu'])

      //this is needed to remove the top level menu item from showing in the submenu
      add_theme_page($this->args['page_slug'],$this->args['page_title'],'',$this->args['page_cap'],$this->args['page_slug'],create_function( '$a', "return null;" ));


      foreach($this->sections as $k => $section)

      add_theme_page(
      $this->args['page_slug'],
      $section['title'],
      $section['title'],
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab='.$k,
      create_function( '$a', "return null;" )
      );



      if(true === $this->args['show_import_export'])

      add_theme_page(
      $this->args['page_slug'],
      __('Import / Export', 'nhp-opts'),
      __('Import / Export', 'nhp-opts'),
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab=import_export_default',
      create_function( '$a', "return null;" )
      );

      //if

      foreach($this->extra_tabs as $k => $tab)

      add_theme_page(
      $this->args['page_slug'],
      $tab['title'],
      $tab['title'],
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab='.$k,
      create_function( '$a', "return null;" )
      );


      if(true === $this->args['dev_mode'])

      add_theme_page(
      $this->args['page_slug'],
      __('Dev Mode Info', 'nhp-opts'),
      __('Dev Mode Info', 'nhp-opts'),
      $this->args['page_cap'],
      $this->args['page_slug'].'&tab=dev_mode_default',
      create_function( '$a', "return null;" )
      );

      //if
      //if


      //else
      add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
      add_action('load-'.$this->page, array(&$this, '_load_page'));
      //function






      functions customization






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 13 at 0:40









      Jobbie DaddyJobbie Daddy

      276




      276




















          2 Answers
          2






          active

          oldest

          votes


















          4














          There is an inbuilt function for returning null: __return_null.



          So you can replace create_function('$a', 'return null;'); with just '__return_null' (note the quotes) as it seems $a is not used anyway.



          Or you can use an anonymous function as the argument directly: function($a) return null; (no quotes). Either way since the argument is expecting a function calback.






          share|improve this answer
































            3














            You should be able to change create_function( '$a', "return null;" ) to Anonymous Function (aka Closure) :



            From :



             add_theme_page(
            $this->args['page_slug'],
            __('Dev Mode Info', 'nhp-opts'),
            __('Dev Mode Info', 'nhp-opts'),
            $this->args['page_cap'],
            $this->args['page_slug'].'&tab=dev_mode_default',
            create_function( '$a', "return null;" )
            );


            To :



             add_theme_page(
            $this->args['page_slug'],
            __('Dev Mode Info', 'nhp-opts'),
            __('Dev Mode Info', 'nhp-opts'),
            $this->args['page_cap'],
            $this->args['page_slug'].'&tab=dev_mode_default',
            function($a) return null;
            );


            full code changes :



            function _options_page()
            if($this->args['page_type'] == 'submenu')else
            $this->page = add_theme_page(
            $this->args['page_title'],
            $this->args['menu_title'],
            $this->args['page_cap'],
            $this->args['page_slug'],
            array(&$this, '_options_page_html'),
            $this->args['menu_icon'],
            $this->args['page_position']
            );

            if(true === $this->args['allow_sub_menu'])

            //this is needed to remove the top level menu item from showing in the submenu
            add_theme_page(
            $this->args['page_slug'],
            $this->args['page_title'],
            '',
            $this->args['page_cap'],
            $this->args['page_slug'],
            function($a) return null;
            );


            foreach($this->sections as $k => $section)

            add_theme_page(
            $this->args['page_slug'],
            $section['title'],
            $section['title'],
            $this->args['page_cap'],
            $this->args['page_slug'].'&tab='.$k,
            function($a) return null;
            );



            if(true === $this->args['show_import_export'])

            add_theme_page(
            $this->args['page_slug'],
            __('Import / Export', 'nhp-opts'),
            __('Import / Export', 'nhp-opts'),
            $this->args['page_cap'],
            $this->args['page_slug'].'&tab=import_export_default',
            function($a) return null;
            );

            //if

            foreach($this->extra_tabs as $k => $tab)

            add_theme_page(
            $this->args['page_slug'],
            $tab['title'],
            $tab['title'],
            $this->args['page_cap'],
            $this->args['page_slug'].'&tab='.$k,
            function($a) return null;
            );


            if(true === $this->args['dev_mode'])

            add_theme_page(
            $this->args['page_slug'],
            __('Dev Mode Info', 'nhp-opts'),
            __('Dev Mode Info', 'nhp-opts'),
            $this->args['page_cap'],
            $this->args['page_slug'].'&tab=dev_mode_default',
            function($a) return null;
            );

            //if
            //if


            //else
            add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
            add_action('load-'.$this->page, array(&$this, '_load_page'));
            //function





            share|improve this answer










            New contributor



            Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "110"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f340362%2frefactor-create-function%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              There is an inbuilt function for returning null: __return_null.



              So you can replace create_function('$a', 'return null;'); with just '__return_null' (note the quotes) as it seems $a is not used anyway.



              Or you can use an anonymous function as the argument directly: function($a) return null; (no quotes). Either way since the argument is expecting a function calback.






              share|improve this answer





























                4














                There is an inbuilt function for returning null: __return_null.



                So you can replace create_function('$a', 'return null;'); with just '__return_null' (note the quotes) as it seems $a is not used anyway.



                Or you can use an anonymous function as the argument directly: function($a) return null; (no quotes). Either way since the argument is expecting a function calback.






                share|improve this answer



























                  4












                  4








                  4







                  There is an inbuilt function for returning null: __return_null.



                  So you can replace create_function('$a', 'return null;'); with just '__return_null' (note the quotes) as it seems $a is not used anyway.



                  Or you can use an anonymous function as the argument directly: function($a) return null; (no quotes). Either way since the argument is expecting a function calback.






                  share|improve this answer















                  There is an inbuilt function for returning null: __return_null.



                  So you can replace create_function('$a', 'return null;'); with just '__return_null' (note the quotes) as it seems $a is not used anyway.



                  Or you can use an anonymous function as the argument directly: function($a) return null; (no quotes). Either way since the argument is expecting a function calback.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 13 at 2:09

























                  answered Jun 13 at 1:07









                  majickmajick

                  3,8831724




                  3,8831724























                      3














                      You should be able to change create_function( '$a', "return null;" ) to Anonymous Function (aka Closure) :



                      From :



                       add_theme_page(
                      $this->args['page_slug'],
                      __('Dev Mode Info', 'nhp-opts'),
                      __('Dev Mode Info', 'nhp-opts'),
                      $this->args['page_cap'],
                      $this->args['page_slug'].'&tab=dev_mode_default',
                      create_function( '$a', "return null;" )
                      );


                      To :



                       add_theme_page(
                      $this->args['page_slug'],
                      __('Dev Mode Info', 'nhp-opts'),
                      __('Dev Mode Info', 'nhp-opts'),
                      $this->args['page_cap'],
                      $this->args['page_slug'].'&tab=dev_mode_default',
                      function($a) return null;
                      );


                      full code changes :



                      function _options_page()
                      if($this->args['page_type'] == 'submenu')else
                      $this->page = add_theme_page(
                      $this->args['page_title'],
                      $this->args['menu_title'],
                      $this->args['page_cap'],
                      $this->args['page_slug'],
                      array(&$this, '_options_page_html'),
                      $this->args['menu_icon'],
                      $this->args['page_position']
                      );

                      if(true === $this->args['allow_sub_menu'])

                      //this is needed to remove the top level menu item from showing in the submenu
                      add_theme_page(
                      $this->args['page_slug'],
                      $this->args['page_title'],
                      '',
                      $this->args['page_cap'],
                      $this->args['page_slug'],
                      function($a) return null;
                      );


                      foreach($this->sections as $k => $section)

                      add_theme_page(
                      $this->args['page_slug'],
                      $section['title'],
                      $section['title'],
                      $this->args['page_cap'],
                      $this->args['page_slug'].'&tab='.$k,
                      function($a) return null;
                      );



                      if(true === $this->args['show_import_export'])

                      add_theme_page(
                      $this->args['page_slug'],
                      __('Import / Export', 'nhp-opts'),
                      __('Import / Export', 'nhp-opts'),
                      $this->args['page_cap'],
                      $this->args['page_slug'].'&tab=import_export_default',
                      function($a) return null;
                      );

                      //if

                      foreach($this->extra_tabs as $k => $tab)

                      add_theme_page(
                      $this->args['page_slug'],
                      $tab['title'],
                      $tab['title'],
                      $this->args['page_cap'],
                      $this->args['page_slug'].'&tab='.$k,
                      function($a) return null;
                      );


                      if(true === $this->args['dev_mode'])

                      add_theme_page(
                      $this->args['page_slug'],
                      __('Dev Mode Info', 'nhp-opts'),
                      __('Dev Mode Info', 'nhp-opts'),
                      $this->args['page_cap'],
                      $this->args['page_slug'].'&tab=dev_mode_default',
                      function($a) return null;
                      );

                      //if
                      //if


                      //else
                      add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
                      add_action('load-'.$this->page, array(&$this, '_load_page'));
                      //function





                      share|improve this answer










                      New contributor



                      Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.























                        3














                        You should be able to change create_function( '$a', "return null;" ) to Anonymous Function (aka Closure) :



                        From :



                         add_theme_page(
                        $this->args['page_slug'],
                        __('Dev Mode Info', 'nhp-opts'),
                        __('Dev Mode Info', 'nhp-opts'),
                        $this->args['page_cap'],
                        $this->args['page_slug'].'&tab=dev_mode_default',
                        create_function( '$a', "return null;" )
                        );


                        To :



                         add_theme_page(
                        $this->args['page_slug'],
                        __('Dev Mode Info', 'nhp-opts'),
                        __('Dev Mode Info', 'nhp-opts'),
                        $this->args['page_cap'],
                        $this->args['page_slug'].'&tab=dev_mode_default',
                        function($a) return null;
                        );


                        full code changes :



                        function _options_page()
                        if($this->args['page_type'] == 'submenu')else
                        $this->page = add_theme_page(
                        $this->args['page_title'],
                        $this->args['menu_title'],
                        $this->args['page_cap'],
                        $this->args['page_slug'],
                        array(&$this, '_options_page_html'),
                        $this->args['menu_icon'],
                        $this->args['page_position']
                        );

                        if(true === $this->args['allow_sub_menu'])

                        //this is needed to remove the top level menu item from showing in the submenu
                        add_theme_page(
                        $this->args['page_slug'],
                        $this->args['page_title'],
                        '',
                        $this->args['page_cap'],
                        $this->args['page_slug'],
                        function($a) return null;
                        );


                        foreach($this->sections as $k => $section)

                        add_theme_page(
                        $this->args['page_slug'],
                        $section['title'],
                        $section['title'],
                        $this->args['page_cap'],
                        $this->args['page_slug'].'&tab='.$k,
                        function($a) return null;
                        );



                        if(true === $this->args['show_import_export'])

                        add_theme_page(
                        $this->args['page_slug'],
                        __('Import / Export', 'nhp-opts'),
                        __('Import / Export', 'nhp-opts'),
                        $this->args['page_cap'],
                        $this->args['page_slug'].'&tab=import_export_default',
                        function($a) return null;
                        );

                        //if

                        foreach($this->extra_tabs as $k => $tab)

                        add_theme_page(
                        $this->args['page_slug'],
                        $tab['title'],
                        $tab['title'],
                        $this->args['page_cap'],
                        $this->args['page_slug'].'&tab='.$k,
                        function($a) return null;
                        );


                        if(true === $this->args['dev_mode'])

                        add_theme_page(
                        $this->args['page_slug'],
                        __('Dev Mode Info', 'nhp-opts'),
                        __('Dev Mode Info', 'nhp-opts'),
                        $this->args['page_cap'],
                        $this->args['page_slug'].'&tab=dev_mode_default',
                        function($a) return null;
                        );

                        //if
                        //if


                        //else
                        add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
                        add_action('load-'.$this->page, array(&$this, '_load_page'));
                        //function





                        share|improve this answer










                        New contributor



                        Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





















                          3












                          3








                          3







                          You should be able to change create_function( '$a', "return null;" ) to Anonymous Function (aka Closure) :



                          From :



                           add_theme_page(
                          $this->args['page_slug'],
                          __('Dev Mode Info', 'nhp-opts'),
                          __('Dev Mode Info', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=dev_mode_default',
                          create_function( '$a', "return null;" )
                          );


                          To :



                           add_theme_page(
                          $this->args['page_slug'],
                          __('Dev Mode Info', 'nhp-opts'),
                          __('Dev Mode Info', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=dev_mode_default',
                          function($a) return null;
                          );


                          full code changes :



                          function _options_page()
                          if($this->args['page_type'] == 'submenu')else
                          $this->page = add_theme_page(
                          $this->args['page_title'],
                          $this->args['menu_title'],
                          $this->args['page_cap'],
                          $this->args['page_slug'],
                          array(&$this, '_options_page_html'),
                          $this->args['menu_icon'],
                          $this->args['page_position']
                          );

                          if(true === $this->args['allow_sub_menu'])

                          //this is needed to remove the top level menu item from showing in the submenu
                          add_theme_page(
                          $this->args['page_slug'],
                          $this->args['page_title'],
                          '',
                          $this->args['page_cap'],
                          $this->args['page_slug'],
                          function($a) return null;
                          );


                          foreach($this->sections as $k => $section)

                          add_theme_page(
                          $this->args['page_slug'],
                          $section['title'],
                          $section['title'],
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab='.$k,
                          function($a) return null;
                          );



                          if(true === $this->args['show_import_export'])

                          add_theme_page(
                          $this->args['page_slug'],
                          __('Import / Export', 'nhp-opts'),
                          __('Import / Export', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=import_export_default',
                          function($a) return null;
                          );

                          //if

                          foreach($this->extra_tabs as $k => $tab)

                          add_theme_page(
                          $this->args['page_slug'],
                          $tab['title'],
                          $tab['title'],
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab='.$k,
                          function($a) return null;
                          );


                          if(true === $this->args['dev_mode'])

                          add_theme_page(
                          $this->args['page_slug'],
                          __('Dev Mode Info', 'nhp-opts'),
                          __('Dev Mode Info', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=dev_mode_default',
                          function($a) return null;
                          );

                          //if
                          //if


                          //else
                          add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
                          add_action('load-'.$this->page, array(&$this, '_load_page'));
                          //function





                          share|improve this answer










                          New contributor



                          Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          You should be able to change create_function( '$a', "return null;" ) to Anonymous Function (aka Closure) :



                          From :



                           add_theme_page(
                          $this->args['page_slug'],
                          __('Dev Mode Info', 'nhp-opts'),
                          __('Dev Mode Info', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=dev_mode_default',
                          create_function( '$a', "return null;" )
                          );


                          To :



                           add_theme_page(
                          $this->args['page_slug'],
                          __('Dev Mode Info', 'nhp-opts'),
                          __('Dev Mode Info', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=dev_mode_default',
                          function($a) return null;
                          );


                          full code changes :



                          function _options_page()
                          if($this->args['page_type'] == 'submenu')else
                          $this->page = add_theme_page(
                          $this->args['page_title'],
                          $this->args['menu_title'],
                          $this->args['page_cap'],
                          $this->args['page_slug'],
                          array(&$this, '_options_page_html'),
                          $this->args['menu_icon'],
                          $this->args['page_position']
                          );

                          if(true === $this->args['allow_sub_menu'])

                          //this is needed to remove the top level menu item from showing in the submenu
                          add_theme_page(
                          $this->args['page_slug'],
                          $this->args['page_title'],
                          '',
                          $this->args['page_cap'],
                          $this->args['page_slug'],
                          function($a) return null;
                          );


                          foreach($this->sections as $k => $section)

                          add_theme_page(
                          $this->args['page_slug'],
                          $section['title'],
                          $section['title'],
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab='.$k,
                          function($a) return null;
                          );



                          if(true === $this->args['show_import_export'])

                          add_theme_page(
                          $this->args['page_slug'],
                          __('Import / Export', 'nhp-opts'),
                          __('Import / Export', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=import_export_default',
                          function($a) return null;
                          );

                          //if

                          foreach($this->extra_tabs as $k => $tab)

                          add_theme_page(
                          $this->args['page_slug'],
                          $tab['title'],
                          $tab['title'],
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab='.$k,
                          function($a) return null;
                          );


                          if(true === $this->args['dev_mode'])

                          add_theme_page(
                          $this->args['page_slug'],
                          __('Dev Mode Info', 'nhp-opts'),
                          __('Dev Mode Info', 'nhp-opts'),
                          $this->args['page_cap'],
                          $this->args['page_slug'].'&tab=dev_mode_default',
                          function($a) return null;
                          );

                          //if
                          //if


                          //else
                          add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
                          add_action('load-'.$this->page, array(&$this, '_load_page'));
                          //function






                          share|improve this answer










                          New contributor



                          Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          share|improve this answer



                          share|improve this answer








                          edited Jun 13 at 1:13





















                          New contributor



                          Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          answered Jun 13 at 1:08









                          Adnane ZarroukAdnane Zarrouk

                          295




                          295




                          New contributor



                          Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.




                          New contributor




                          Adnane Zarrouk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to WordPress Development Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f340362%2frefactor-create-function%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                              Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                              Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림