rtCamp notes, day 22 of undefined

Some quick random learnings

  • Enquing JS & CSS files instead of loading them manually via code
add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );

The function register_scripts should contain our code to enque scripts and stylesheets.

public function register_scripts() {
		wp_enqueue_style( 'some-id', 'some-url-to-file', array(), '1.0.0' );
	}
  • Always try to decrease the number of times the code repeats, instead put them in functions or something.
  • Creating static variables in classes and calling them in other classes with namespace
  • wp_kses() -> used to strip out unnecessary tags, only certain tags are allowed.
  • wp_kses_allowed_html() -> view allowed html tags
  • wp_kses() -> pass second argument as array to add custom tags

array( 'b' => array( 'id' => array() ) ) )

This will add bold tag and attribute for it.

Leave a Reply

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