name = $name; } /** * function to bind short-code to WordPress */ public function add() { // add shortcode to WordPress hook $this->_c()->add_shortcode( $this->name, array( $this, 'logic' ) ); } /** * function to check if post has this shortcode or not * @return mixed result of operation */ public function haveShortcode() { global $post; $content = $post->post_content; return ( filter_var( preg_match( '/.*(\[' . $this->name . '\]).*/', $content ), FILTER_VALIDATE_BOOLEAN ) ); } /** * main logic for short code * * @param $attrs shortcode attributes * * @return mixed short-code render string */ abstract public function logic( $attrs ); }