Examples for our post in Nelio Software.
Coding Standards WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register the main hooks related to the admin area functionality of the plugin. | |
* | |
* @since 1.0.0 | |
* @access private | |
*/ | |
private function define_admin_hooks() { | |
// If the plugin is configured, we can load everything else. | |
$reference_post_type = Nelio_Content_Reference_Post_Type_Register::instance(); | |
$reference_post_type->defineAdminHooks(); | |
$pluginAdmin = new Nelio_Content_Admin( $this->get_plugin_name(), $this->get_version() ); | |
add_action( 'wp_loaded', array( Nelio_Content_Settings::instance(), 'defineAdminHooks' ) ); | |
add_action( 'wp_loaded', array( $pluginAdmin, 'add_admin_menus' ) ); | |
$ncte = new nelio_content_tinymce_extensions(); | |
$ncte->define_admin_hooks(); | |
$aux = new NelioContentExternalFeaturedImageAdmin(); | |
$aux->defineAdminHooks(); | |
// ... | |
}//end define_admin_hooks() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($users[$user_id])){ | |
$users[$user_id] = $this->get_user_info($user_id,'lazy'); | |
}//endif | |
$this->set_admin_user($user_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
if ( ! isset( $users[ $user_id ] ) ) { | |
$users[ $user_id ] = $this->get_user_info( $user_id, 'lazy' ); | |
}//endif | |
$this->set_admin_user( $user_id ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
var users = loadUsers(); | |
if ( 'undefined' !== typeof users[ userId ] ) { | |
users[ userId ] = loadUser( userId ); | |
}//end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $length == 1 ) { | |
// Some action. | |
}//end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( 1 == $length ) { | |
// Some action. | |
}//end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( true == $the_force ) { | |
$victorious = you_will( $be ); | |
}//end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
isset( $var ) || $var = some_function(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! isset( $var ) ) { | |
$var = some_function(); | |
}//end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function register_menus() { | |
$menu_list = array(); | |
// ... | |
}//end register_menus() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addCustomButton() { | |
var customButton = new Button(); | |
// ... | |
}//end addCustomButton() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function enqueue_scripts() { | |
$post_type_object = $this->get_post_type_object(); | |
wp_enqueue_script( | |
'nelio-content-script', | |
NELIO_CONTENT_ADMIN_URL . '/js/script.min.js', | |
array( 'jquery', 'underscore' ), | |
$this->get_version(), | |
true | |
); | |
wp_localize_script( | |
'nelio-content-script', | |
'NelioContentScript', | |
array( | |
'canUserPublishPosts' => current_user_can( $post_type_obj->cap->publish_posts ), | |
'canUserEditPublishedPosts' => current_user_can( $post_type_obj->cap->edit_published_posts ), | |
'i18n' => array( | |
'ok' => _x( 'OK', 'command', 'nelio-content' ), | |
'cancel' => _x( 'Cancel', 'command', 'nelio-content' ), | |
'save' => _x( 'Save', 'command', 'nelio-content' ), | |
'published' => _x( 'Published', 'text', 'nelio-content' ), | |
), | |
) | |
); | |
}//end enqueue_scripts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment