define("SFWP_THEME_DIR" , get_template_directory() );
define("SFWP_THEME_URL" , get_bloginfo("template_directory") );
define("SFWP_CSS_DIR" , SFWP_THEME_DIR."/css/");
define("SFWP_CSS_URL" , SFWP_THEME_URL."/css/");
define("SFWP_JS_DIR" , SFWP_THEME_DIR."/js/");
define("SFWP_JS_URL" , SFWP_THEME_URL."/js/");
define("SFWP_IMG_DIR" , SFWP_THEME_DIR."/img/");
define("SFWP_IMG_URL" , SFWP_THEME_URL."/img/");
define("SFWP_TEMPLATE_PARTS_DIR" , SFWP_THEME_DIR."/templates/");
trait SFWP_Set{
/*setter*/
public function set_slug( $slug_ = "" ){
$this->slug = $slug_;
}
public function add_css($css_ = array()){
if(is_array($css_)){
foreach($css_ as $css){
$this->css[] = $css;
}
}
elseif(is_string($css_)){
$this->css[] = $css_;
}
else{
return $this;
}
}
public function add_js($js_ = array()){
if(is_array($js_)){
foreach($js_ as $js){
$this->js[] = $js;
}
}
elseif(is_string($js_)){
$this->js[] = $js_;
}
else{
return $this;
}
}
public function register_custom_post_types( ){
foreach($this->custom_post_types as $key => $jp_name){
$labels = array(
'name' => _x( $jp_name, $key ),
'singular_name' => _x( $jp_name, $key ),
'add_new' => _x( "{$jp_name}を追加する", $key ),
'add_new_item' => _x( "{$jp_name}を追加する", $key ),
'edit_item' => _x( "{$jp_name}を編集する", $key ),
'new_item' => _x( "新規{$jp_name}", $key ),
'view_item' => _x( "{$jp_name}を見る", $key ),
'search_items' => _x( "{$jp_name}を検索する", $key ),
'not_found' => _x( "{$jp_name}が見つかりません", $key ),
'not_found_in_trash' => _x( "{$jp_name}がゴミ箱にありません", $key ),
'parent_item_colon' => _x( "Parent {$key}:", $key ),
'menu_name' => _x( $jp_name, $key ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' , "custom-fields" ),
'taxonomies' => array( 'category' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( $key, $args );
}
}
}
/*
trait Helper
depends on wordpress.
*/
trait SFWP_Html_Helper{
public function a($url_ ="", $content_ ="" , $attr_=array() ){
if(
strpos($url_ , "http://") !== false
|| strpos($url_ , "https://") !== false
|| strpos($url_ , "tel:") !== false
|| strpos($url_ , "mailto:") !== false
){
$href = $url_;
}
else{
$href = get_home_url()."/".$url_;
}
$tag = " $value) {
$tag.= $key.'="'.$value.'" ';
}
}
$tag .= ">" . $content_ . "";
echo $tag;
}
public function img($filename_ ="", $attr_ ="" , $echo = true){
$fileUrl = "";
foreach(array("png", "jpg" , "jpeg" , "gif") as $extension){
if( is_readable( SFWP_IMG_DIR."{$filename_}.{$extension}" ) ){
$fileUrl = SFWP_IMG_URL."{$filename_}.{$extension}";
break;
}
}
if(!$fileUrl){
if($echo){
echo "";
return "";
}
else{
return "" ;
}
}
//attrが文字列だったらclassに、そうでないならkey=>valueにという横着仕様
if($attr_){
//文字列ならclass
if(is_string($attr_)){
$imgtag = '
';
if($echo){
echo $imgtag;
return "";
}
else{
return $imgtag;
}
}
//文字列でないならattr.each key=>value
if(is_array($attr_)){
$imgtag = '
$value){
$imgtag .= $key.'="'.$value.'" ';
}
$imgtag .= ">";
if($echo){
echo $imgtag;
return "";
}
else{
return $imgtag;
}
}
}
$imgtag = '
';
if($echo){
echo $imgtag;
return "";
}
else{
return $imgtag;
}
}
public function putCss($filename_ = "" , $attr_ = array() , $inline_ = false){
if( is_readable( SFWP_CSS_DIR .$filename_ ) ){
if($attr_){
$tag = '$value){
$tag .= $key.'="'.$value.'" ';
}
$tag .= '>';
echo $tag;
}
else{
echo ' ';
}
}
echo "";
}
public function putJs($filename_ = "" , $attr_ = array() , $inline_ = false){
if( is_readable( SFWP_JS_DIR.$filename_ ) ){
if($attr_){
$tag = '';
echo $tag;
}
else{
echo '';
}
}
echo "";
}
public function putCssAll(){
echo '';//テーマcss(必須)
foreach($this->css as $value){
if(is_string($value)){
$this->putCss($value);
}
}
}
public function putJsAll( ){
foreach($this->js as $filename){
$this->putJs($filename);
}
}
}
Fatal error: Trait "SFWP_Html_Helper" not found in /home/users/2/her.jp-angelanara/web/wp-content/plugins/sfwp/class-sfwp.php on line 33