Unregister Custom Post Types In WordPress


/**
* Unregister Custom Post Types
*
*/

function custom_unregister_theme_post_types() {
global $wp_post_types;
foreach( array( 'portfolio', 'clients', 'team', 'testimonials' ) as $post_type ) {
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
}
}
}
add_action( 'init', 'custom_unregister_theme_post_types', 20 );

Credit goes to Themify for posting an actual solution that worked: Themify

Tweet It. Share It.

See more Code Snippet, php, Programming, Wordpress

Software Design Patterns

“A design pattern is a general reusable solution to a common occurring problem within given context in software design.” (Wikipedia,  Software_design_pattern)

Design patterns aren’t completed solutions…they are more like templates that can be used to solve problems and help to organize code. There are three main categories of design patterns: creational, behavioral, and structural. Within these three categories there is a variety of design patterns.

Types of Patterns

Creational  

  • Singleton
  • Factory (simplified)
  • Factory Method
  • Abstract factory
  • Builder
  • Prototype
  • Object Pool

Behavioral

  • Chain of responsibility
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Observer
  • Strategy
  • Template method
  • Visitor
  • Null object

Structural

  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Flyweight
  • Memento
  • Proxy

The most common design pattern that I come in the most contact with is the observer pattern from the behavioral category. The observer pattern is used in the model view controller (MVC) architectural pattern. This pattern is used to decouple the model from the view. MVC is often used in swing (JAVA) and .net development for events management. MVC is also commonly used in Php frameworks. The majority of frameworks including Codeigniter, FuelPHP, Larvel, and just about every Php framework use this design pattern.

JAVA Design Patterns

For the conclusion of this research I will try to discuss some of the more commonly used patterns in JAVA. One pattern that is commonly used in JAVA is the Singleton pattern. The Singleton pattern is used to encapsulate the creation of an object in order to maintain control over it. This allows lazy instantiation and ensures that only one object is created. One example of when this is used is for a remote database connection.

Another commonly used pattern is the Factory Method pattern. This pattern is used when it must be decided at run time which one of several compatible classes is to be instantiated. This pattern is used throughout the Java API. A prime example of this pattern being used is the collator class’s getInstance() method which returns a collation object.

Although I only covered some of the basic Creational patterns used in JAVA there are many other patterns used in JAVA development. Design patterns are a valuable tool for OOP design for a number of reasons. They provide a solution to a problem in a context while providing a vocabulary for discussing OOP design at a significant level of abstraction and they serve as a glossary of idioms that will assist in understanding common complex solutions to design problems.

Tweet It. Share It.

See more Java, Programming