Use .php file as page instead of wordpress page & template file?

Yes you can do this but creating template like usercp.php . (1) First create usercp.php template and then this one line at first of template. update_post_meta(get_the_ID(), ‘usercp’, 111); (2) Then create page and assign template. (2) Then go to your functions.php file and add this code add_action(‘template_redirect’, ‘setPrivateTemplate’); function setPrivateTemplate() { if (get_post_meta(get_the_ID(), ‘usercp’, true) … Read more

Echo a function inside a function

echo is a PHP language construct which pushes values to the output buffer. It does not have a return value, so concatenating it with a string would cause everything after the echo to immediately be sent to the output buffer, and everything prior to echo to compose the concatenated string. This is such a misuse … Read more

How can I make an object available through the entire site?

Do not use globals. Ever. You don’t need your object everywhere. You need it only where your code is running. Globals are hard to debug, everyone can write to them or just delete them. Unit tests with globals are possible, but awkward. You have to change the global state for each test, ie. something outside … Read more

a:0:{} is replaced into database as s:6:”a:0:{}”;

API calls are API calls, not database writes. What and how information is stored in the DB is usually best left as an unknown since, unless explicitly defined in the API, it might change. Specifically in this case, wordpress will serialize the value being passed, and since you are passing a string it is serialized … Read more