How much PHP knowledge is needed for WordPress and where can you easily learn PHP for WordPress?

·

·

, ,

💡 To learn WordPress Theme and Plugin development, the following PHP topics would be more than sufficient. This PHP for WordPress guideline is provided by Kamal Ahmed, who has worked for WPDevelopers, rtCamps, UberSuggest, SiteCare, and other companies.

  1. Variables & Data Types: (string, integer, float, array, object). Minimum 15 array functions & 10 string functions.
  2. Functions and Scopes.
  3. Loops (for, foreach, while) & Conditions (if, else, switch, try catch).
  4. Working with FORMS: get, post, delete, put difference. Validating and Escaping user submitted data.
  5. Global variables: GET, POST, REQUEST differences and usage.
  6. Include and Require
  7. For Object Oriented PHP:
    1. Class,
    2. Object,
    3. Class property,
    4. Class method,
    5. Visibility,
    6. Static,
    7. Inheritance
  8. A little intermediate or relatively less common topics but very important and found sometimes in plugins and themes.
    1. Interface, traits, Singleton, Magic Methods, Namespace etc.
    2. Output Buffering, SESSION, COOKIES, Working with APIs using curl. Date and Times,
    3. Working with files (opening, reading, writing etc)

The most commonly used Functions for manipulating Arrays in PHP.

Please see the documentation for example and details understanding.

Array Functions in PHP

  1. sizeof($array): Use this function to find out how many elements an array contains

  2. array_values($array): Use this function to retrieve all the values from an associative array.

  3. array_keys($array): Use this function to retrieve all the keys from an associative array.

  4. array_pop($array): Use this function to remove an element from the end of an array.

  5. array_push($array, $value): This function adds an element to the end of an array.

  6. array_shift($array): This function removes an element from the beginning of an array.

  7. array_unshift($array, $value): This function adds an element to the beginning of an array.

  8. array_map($callback, $array1): This function returns an array containing all the elements of array1 after applying the callback function to each one. You can pass more than one array. The number of parameters that the callback function accepts should match the number of arrays passed to the array_map()

  9. sort($array): This function sorts the elements of an array in ascending order. String values will be arranged in ascending alphabetical order. Other sorting functions include asort(), arsort(), ksort(), krsort() and rsort().

  10. array_reverse($array): This function reverses the order of elements in an array.

  11. array_merge($array): Use this function when you need to combine data from two or more arrays into a single structure

  12. array_rand($array): This function selects one or more random elements from an array.

  13. array_search($search, $array): This function searches the values in an array for a match to the search term, and returns the corresponding key if found. If more than one match exists, the key of the first matching value is returned.

  14. array_slice($array, $offset, $length): Use this function to break a larger array into smaller ones.

  15. array_unique($array): Use this function when you need to remove non-unique elements from an array

  16. extract($array): Import variables into the current symbol table from an array. For Better understanding read the doc about this function. It is very nice. Its opposite is compact().

  17. array_key_exists($key, $array): This functions returns TRUE if the given key is set in the array.

  18. in_array($searched_value, $array): This functions returns TRUE if the given value exists in the array

The most commonly used Functions for manipulating Strings in PHP

  1. substr(): This function returns the part of the string as an output.

  2. strlen(): This function returns the length of the string

  3. trim(): This function removes the white-spaces from both start and the end of the string.

  4. ltrim(): This function removes the white-spaces from the left part of the string.

  5. rtrim(): This function removes the white-spaces from the right part of the string.

  6. strtolower(): This function converts the string to lower case

  7. strtoupper(): This function converts the string to upper case

  8. str_replace(): The str_replace() function replaces some characters with some other characters in a string.

  9. explode(): This function breaks the string into array on the basis of delimiter passed.

  10. implode(): This function join array elements with a string on the basis of delimiter passed.

Resources

  1. PHP for Beginners (2023 Edition) by Jeffery Way
  1. Learn PHP The Right Way by Gio

Credits: Kamal Ahmed


Meet the author

Faisal Ahammad

I’m working as Support Engineer at Saturday Drive Inc (AKA Ninja Forms) and General Translation Editor (GTE) for the #bn_BD 🇧🇩 language. As an active contributor to WordPress and open-source projects, I have translated over 60 themes, plugins, and WordPress core. I also have a small YouTube channel where I share my knowledge.


Leave a Reply

Your email address will not be published. Required fields are marked *