/** * Factory method * @param int $id * @return MslsOptions */ public static function create($id = 0) { if (is_admin()) { $id = (int) $id; if (MslsContentTypes::create()->is_taxonomy()) { return MslsOptionsTax::create($id); } return new MslsOptionsPost($id); } if (self::is_main_page()) { return new MslsOptions(); } elseif (self::is_tax_page()) { return MslsOptionsTax::create(); } elseif (self::is_query_page()) { return MslsOptionsQuery::create(); } global $wp_query; return new MslsOptionsPost($wp_query->get_queried_object_id()); }
/** * Factory method * * @param int $id * * @return MslsOptions */ public static function create($id = 0) { if (is_admin()) { $id = (int) $id; if (MslsContentTypes::create()->is_taxonomy()) { return MslsOptionsTax::create($id); } return new MslsOptionsPost($id); } if (self::is_main_page()) { $options = new MslsOptions(); } elseif (self::is_tax_page()) { $options = MslsOptionsTax::create(); } elseif (self::is_query_page()) { $options = MslsOptionsQuery::create(); } else { $options = new MslsOptionsPost(get_queried_object_id()); } add_filter('check_url', array($options, 'check_for_blog_slug'), 10, 2); return $options; }
/** * Verify the static create-method */ function test_create_method() { $this->assertNull(MslsOptionsQuery::create()); return new MslsOptionsQuery(); }