Is there a common structure for a wordpress formular?
I highly recommand you to see this link. This will help you to respect coding standards in WP. EDIT : add link I give in comments
I highly recommand you to see this link. This will help you to respect coding standards in WP. EDIT : add link I give in comments
Are the above practices both valid? I’ve never seen anyone use method B. Functions declared inside functions still need to be unique. Therefore, just because they are declared inside another function does not guarantee that there won’t be a name conflict. As far as I can tell, there is no useful purpose in doing this. … Read more
You can avoid using (new …)-> by using a static method, which creates the new instance internally. Combining this with the magic __toString method allows you to directly echo the created instance. Here is how to write it: <?php class Post_Share { /** * Using Post_Share::generate() will directly return the new instance, * so (new … Read more
As fuxia says, the most elegant way to adhere to the rule is to just not include that code. If a file is written properly then it’s not required to be safe. Keep in mind that PSR12 is just one set of standards, and WordPress and many plugins do not follow it. They are more … Read more
I can’t find any documentation of this class family. Can you explain how it works? That’s because there is none, there is no standard. Lets follow what happened: Some core blocks contain other blocks. ( 2 to be specific ) Those blocks have a class on the element that contains those blocks so that it … Read more
You can use the Theme-Check plugin. The theme check plugin is an easy way to test your theme and make sure it’s up to spec with the latest theme review standards. With it, you can run all the same automated testing tools on your theme that WordPress.org uses for theme submissions. The tests are run … Read more
Because on the minimum version required it isn’t always available since the SPL can be disabled on PHP 5.2 and below. The majority of installs running WordPress have it, but not all, and it’s the same reason autoloaders and Iterators aren’t used. Moving to v5.3 as a minimum PHP would fix this however as the … Read more
I would say the section Constants in the WordPress: PHP Documentation Standards is pretty clear. It should look like this: /** * Summary. * * @since x.x.x (if available) * @var type $var Description. */ define( ‘MY_CONST’, ‘Hello’ );
This is mostly just for readability. The semantics change before and after a parenthesis, and we are used to read spaces as word separators in western languages, so we can read such code faster. Another point is search: If you want to search for all changes on variables beginning with $post it is easier to … Read more
You cannot use constants or anything other than actual strings with translation functions. This is because the code that reads your code, and produces the translatable strings does not actually run your code, it is reading your code. Here is a more detailed post on the topic: http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ But the short version is this: This … Read more