DEV Community

Michael Ryvkin
Michael Ryvkin

Posted on • Originally published at gyrocode.com

5 WordPress interview questions

See some WordPress interview questions below to sharpen your programming skills and practice.

1. Using the line numbers please describe what problems are preventing the following PHP/WordPress code from working properly as well as changes you would make to optimize this code to make it more efficient, if any.

<?
class User {
   public function __get($username) {
      if(is_user_logged_in($username)){
         return 'valid';
      }

      return 'invalid';
   }
}

$e = new User();
if(empty($e->checkinfo))
   $x = 0;

//Menu
for($i = 0; $i < 10; $i++) {
   echo '<ul id="'.$i."">';
   for($j = 0; $j < 10; $j++) {
      if($x == 0)
         break

   echo '<li id=".'$j'.">Menu Item'.$j.'</li>';
   }

   if($x =! 0){
      echo '</ul>';
   }
}

/*Some more menu stuff here...*/
$options = get_option( 'theme-options' );
$colors = array('coral','toffee','sunshine','wildflower','wine');
$i = 0;
echo "<select name='theme-options[color]'>"
while($i < 5); {
echo '<option value="$colors[$i]"'. ((esc_attr( $options['color']== $color[$i])? 'selected="selected"': '' ).'>$colors[$i]</option>';
$i++;
}
echo '</select>';
Enter fullscreen mode Exit fullscreen mode

2. Using JavaScript and jQuery please provide code that will remove placeholders in the template on page load to produce result shown below.

Template:

<div class="class-replace">
   <p>
      <a href="http://[SITE].com">[NAME]</a> © [START]-[CURRENT]. All rights reserved
   </p>
</div>
Enter fullscreen mode Exit fullscreen mode

Expected result:

<div class="copyright">
   <p>
      <a href="http://foobar.com">FooBar</a> © 2011-2017. All rights reserved
   </p>
</div>
Enter fullscreen mode Exit fullscreen mode

3. What does the following function remove from a WordPress users admin area?

function remove_stuff ( $actions )
   if( !is_super_admin() && !current_user_can( 'edit_theme_options' ) ) {
      unset($actions['inline hide-if-no-js']);
      return $actions;
   } else {
      return $actions;
   }
}
add_filter( 'page_row_actions', 'remove_stuff' );
add_filter( 'post_row_actions', 'remove_stuff' );
Enter fullscreen mode Exit fullscreen mode

4. Some users find it difficult to insert media from a URL via the media uploader. Since 98% of our users don’t use that tab we would like to remove it. Please provide an example of how you would remove that tab for all users.

5. Users who aren’t super admins or cannot edit theme options are not permitted to create new pages. Even with that capability removed, WordPress still shows the “Add New button. Please provide an example of how you would remove this button.

Top comments (3)

Collapse
 
andy profile image
Andy Zhao (he/him)

Thanks for the article, I have some folks who would find this useful.

Now, the question is, are you going to show your answers? 😏

Collapse
 
gyrocode profile image
Michael Ryvkin

It may be unethical since these are actual interview questions that I have been asked recently. I don't want anyone to find easy answers, just to be able to practice and sharpen their skill.

Collapse
 
andy profile image
Andy Zhao (he/him)

Ah, understandable. I'll make sure my buddies take a good stab at it first then.