Bird
0
0

Find the mistake in this plugin code:

medium📝 Debug Q7 of 15
Wordpress - Plugins and Extensibility
Find the mistake in this plugin code:
add_filter('the_content', 'modify_content');\nfunction modify_content($content) {\n  $content = strtoupper($content);\n}
AFunction name must be 'filter_content'
BFilter name 'the_content' is invalid
Cstrtoupper cannot be used in plugins
DFunction does not return the modified content
Step-by-Step Solution
Solution:
  1. Step 1: Check function behavior

    The function modifies $content but does not return it, so filter output is unchanged.
  2. Step 2: Validate filter and function name

    'the_content' is a valid filter and function name can be arbitrary.
  3. Final Answer:

    Function does not return the modified content -> Option D
  4. Quick Check:

    Filters must return modified value [OK]
Quick Trick: Always return modified content in filters [OK]
Common Mistakes:
  • Forgetting to return filtered value
  • Thinking filter name is wrong
  • Assuming function name is fixed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes