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>';
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>
Expected result:
<div class="copyright">
<p>
<a href="http://foobar.com">FooBar</a> © 2011-2017. All rights reserved
</p>
</div>
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' );
I have never faced this code type question, but I think I should prepare for it.
Anyway thanks, Michael.