Title: ace0930's Replies | WordPress.org

---

# ace0930

  [  ](https://wordpress.org/support/users/ace0930/)

 *   [Profile](https://wordpress.org/support/users/ace0930/)
 *   [Topics Started](https://wordpress.org/support/users/ace0930/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ace0930/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ace0930/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ace0930/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ace0930/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ace0930/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 74 total)

1 [2](https://wordpress.org/support/users/ace0930/replies/page/2/?output_format=md)
[3](https://wordpress.org/support/users/ace0930/replies/page/3/?output_format=md)
[4](https://wordpress.org/support/users/ace0930/replies/page/4/?output_format=md)
[5](https://wordpress.org/support/users/ace0930/replies/page/5/?output_format=md)
[→](https://wordpress.org/support/users/ace0930/replies/page/2/?output_format=md)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Theme Updater](https://wordpress.org/support/topic/theme-updater-2/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/theme-updater-2/#post-17019641)
 * [@greenshady](https://wordpress.org/support/users/greenshady/) Hi, I’m trying
   to use the hook `pre_set_site_transient_update_themes` to receive update ( for
   theme ) from my own API. I’m following the turtorial [here](https://make.wordpress.org/core/2020/07/30/recommended-usage-of-the-updates-api-to-support-the-auto-updates-ui-for-plugins-and-themes-in-wordpress-5-5/),
   but I saw others articles has this line of code `if (empty($transient->checked)){
   return $transient; }` which I’m not sure what it does and if I need it. Thank
   you!
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Bug with using getImageData](https://wordpress.org/support/topic/bug-with-using-getimagedata/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years ago](https://wordpress.org/support/topic/bug-with-using-getimagedata/#post-16910408)
 * Update: Use offsetX and offsetY instead.
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [How WordPress get the base URL](https://wordpress.org/support/topic/how-wordpress-get-the-base-url/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/how-wordpress-get-the-base-url/#post-16208796)
 * [@hirenbhanderi](https://wordpress.org/support/users/hirenbhanderi/) Exactly,
   but how does WordPress get the base URL `localhost/example` before putting it
   into the `wp_option` table, that’s what I’m asking…
 * As I have mentioned that the `$_SERVER['SERVER_NAME']` only returns `localhost`,
   so I wonder how WordPress finds `localhost/example`.
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [How WordPress get the base URL](https://wordpress.org/support/topic/how-wordpress-get-the-base-url/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/how-wordpress-get-the-base-url/#post-16208131)
 * [@hirenbhanderi](https://wordpress.org/support/users/hirenbhanderi/) Hi, `get_site_url()`
   is also using `get_option ( 'siteurl' )` if you look at the source code.
 * I’m not asking how to get the base URL like which function to use, I’m asking
   how WordPress gets the `siteurl`…Haha
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Sequence of admin_post and admin_menu](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/#post-16205563)
 * [@threadi](https://wordpress.org/support/users/threadi/) You saved my day, thank
   you so much!
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Sequence of admin_post and admin_menu](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/#post-16205497)
 * [@threadi](https://wordpress.org/support/users/threadi/) To be honest, I still
   do not fully understand. But do you mean the function `handle_data ()` will not
   be include/require on the form page? If it’s true, then my question is solved.
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Sequence of admin_post and admin_menu](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/#post-16205297)
 * [@threadi](https://wordpress.org/support/users/threadi/) From the [doc](https://www.php.net/manual/en/function.header.php)
 * > Remember that header() must be called before any actual output is sent, either
   > by normal HTML tags, blank lines in a file, or from PHP.
 * Normally, we will have another file/script to handle the form like, right?
    Assume`
   index.php` has a form and it looks like this:
 *     ```
       <form action="process.php" method="post"></form>
       ```
   
 * Then in the `process.php` file, we use `$_POST` to get the data like this ( call
   this “example-1” for later reference ):
 *     ```
       $name = $_POST['name'];
   
       header ( "Location: https://example.com" ); // Redirect user to https://example.com after processing the data.
       ```
   
 * But if we put the processing code above on the same file ( `index.php` ) and 
   it looks like this ( call this “example-2” for later reference ):
 *     ```
       <form action="process.php" method="post"></form>
   
       <?php
       $name = $_POST['name'];
   
       header ( "Location: https://example.com" );
       ?>
       ```
   
 * It would cause an error because there is already an output ( the form ) before
   the `header ()`.
 * Now let’s get back to the “WordPress” way of handling form, we will use the hook`
   admin_post_{$action}` with a function like:
 *     ```
       add_action( admin_post_handle_data, handle_data );
       ```
   
 *  Then we write the processing code inside `handle_data` like the below:
 *     ```
       function handle_data () {
          $name = $_POST['name'];
   
          header ( "Location: https://example.com" );
       }
       ```
   
 * The form page is created by `add_menu_page` with the `admin_menu` hook.
 * My question is:
    1) Will this function `handle_data ()` be include/require on
   the form page? If it does, it will look like the “example-2”.
 * 2) If the question “1)” is a yes, then the sequence matter, whether it’s `admin_post`
   first or `admin_menu` first. If it’s `admin_post` first, then the function `handle_data()`
   is before the form; If it’s the `admin_menu` first, then the function `handle_data()`
   is after the form.
 * Or am I complicating it, WordPress will just do the traditional way like “example-
   1” where the processing code is in another script/file?
    -  This reply was modified 3 years, 8 months ago by [ace0930](https://wordpress.org/support/users/ace0930/).
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Sequence of admin_post and admin_menu](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sequence-of-admin_post-and-admin_menu/#post-16205190)
 * [@threadi](https://wordpress.org/support/users/threadi/) Hi, sorry but I don’t
   think you understand the question…
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [SQL – Single quotes and backticks for query](https://wordpress.org/support/topic/sql-single-quotes-and-backticks-for-query/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-single-quotes-and-backticks-for-query/#post-16203000)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) It returns `NULL` when
   I echo `prepare ()` if I `%s` the table name.
 * And I found this line in the source code:
    `$query = preg_replace( '/(?<!%)%s/',"'%
   s'", $query ); // Quote the strings, avoiding escaped strings like %%s.`
 * I believe it becomes `'table_name'` ( note the quotes ) if `%s` the table name,
   and `'table_name'` is different from `table_name`.
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Passing function into wp_safe_redirect](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/#post-16202949)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) Nonono, you didn’t get
   the point. I didn’t put the `wp_safe_redirect` on the first line of the page 
   like:
 *     ```
       <?php wp_safe_redirect ( $example ); ?>
   
       <form></form>
       ```
   
 * Instead, it’s in a function that would be called once the form is submitted to
   the `admin-post.php` with this [hook](https://developer.wordpress.org/reference/hooks/admin_post_action/).
   And it looks like this:
 *     ```
       <?php function send () { wp_safe_redirect ( $example ); } ?>
   
       <form></form>
       ```
   
 * Which mean the `wp_safe_redirect ( $example )` will not trigger until the function
   is called.
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [SQL – Single quotes and backticks for query](https://wordpress.org/support/topic/sql-single-quotes-and-backticks-for-query/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-single-quotes-and-backticks-for-query/#post-16198609)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) Is that mean the `$table_name`
   shouldn’t be replace by `%s`like the below:
    `$wpdb -> prepare ( "SELECT !value!
   FROM !$table_name! WHERE !name! = %s", $name )`
 * Instead and although the below matches the principle of `sprintf` but it won’t
   work with `$wpdb -> prepare`:
    `$wpdb -> prepare ( "SELECT !value! FROM %s WHERE!
   name! = %s", array ( $table_name, $name ) )`
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Passing function into wp_safe_redirect](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/#post-16198591)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) Nope, it seems you misunderstood
   my point. It’s my fault not to mention that the redirect code is in a function
   that will be triggered after the form is submitted using this [method](https://developer.wordpress.org/reference/hooks/admin_post_action/).
   So the redirect code is not on the page itself…
 * Thank you so much for your advice!
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Passing function into wp_safe_redirect](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/#post-16196049)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) Okay, cannot believe
   this mistake took me two days, I think I know why.
 * Because the action of the form is set to `admin-post.php`, of course, the current
   URL would always be that…LOL
 * But you may still explain why `$_SERVER['REQUEST_URI']` may cause so many redirect
   error.
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [SQL – Single quotes and backticks for query](https://wordpress.org/support/topic/sql-single-quotes-and-backticks-for-query/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-single-quotes-and-backticks-for-query/#post-16195363)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) I found a relevant question
   although I don’t understand what the answer is talking about: [https://wordpress.stackexchange.com/questions/25764/cant-pass-table-to-wpdb-prepare](https://wordpress.stackexchange.com/questions/25764/cant-pass-table-to-wpdb-prepare)
 * > quotation marks are added to the table name
 * So `$table_name = $wpdb -> prefix . testing;` will become `"wp_testing"` according
   to the answer? Why is that so?
 * And you said:
 * > Even though including a variable in the first string arg works, it’s incorrect.
   > All vars should be passed in the second arg’s array.
 * 🙂
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Passing function into wp_safe_redirect](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/)
 *  Thread Starter [ace0930](https://wordpress.org/support/users/ace0930/)
 * (@ace0930)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/passing-function-into-wp_safe_redirect/#post-16195142)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) I have also tried:
 *     ```
       $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
       ```
   
 * It redirects to: `https://example.com/wp-admin/admin-post.php?`.
 * With the original code:
    `https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']`
 * It always redirects to `https://example.com/wp-admin/admin-post.php`

Viewing 15 replies - 1 through 15 (of 74 total)

1 [2](https://wordpress.org/support/users/ace0930/replies/page/2/?output_format=md)
[3](https://wordpress.org/support/users/ace0930/replies/page/3/?output_format=md)
[4](https://wordpress.org/support/users/ace0930/replies/page/4/?output_format=md)
[5](https://wordpress.org/support/users/ace0930/replies/page/5/?output_format=md)
[→](https://wordpress.org/support/users/ace0930/replies/page/2/?output_format=md)