xml 用于PhpStorm的WordPress实时模板

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 用于PhpStorm的WordPress实时模板相关的知识,希望对你有一定的参考价值。

1. Close PhpStorm.

2. Download [`WordPress.xml`](https://gist.github.com/Rarst/183c38c499515b6d8609/raw/WordPress.xml) configuration file from this gist.

3. Place file into `.WebIdeXX/config/templates` in your user profile directory, [differs by operating system](http://www.jetbrains.com/phpstorm/webhelp/project-and-ide-settings.html).

4. Restart PhpStorm.

5. `WordPress` template group should be available in `Settings` > `Live Templates`.

6. Suggest functions to add in comments! :)
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="WordPress">
  <template name="aa" value="add_action( '$hook$', '$callback$' );&#10;$END$" description="add_action" toReformat="false" toShortenFQNames="true">
    <variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="callback" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="false" />
      <option name="HTML" value="false" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="aam" value="add_action( '$hook$', array( $class$, '$method$' ) );$END$" description="add_action &gt; method" toReformat="false" toShortenFQNames="true">
    <variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="class" expression="&quot;$this&quot;" defaultValue="" alwaysStopAt="true" />
    <variable name="method" expression="hook" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="false" />
      <option name="HTML" value="false" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="afm" value="add_filter( '$hook$', array( $class$, '$method$' ) );$END$" description="add_filter &gt; method" toReformat="false" toShortenFQNames="true">
    <variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="class" expression="&quot;$this&quot;" defaultValue="" alwaysStopAt="true" />
    <variable name="method" expression="hook" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="false" />
      <option name="HTML" value="false" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="ea" value="esc_attr( $SELECTION$ )" description="esc_attr" toReformat="false" toShortenFQNames="true">
    <context>
      <option name="HTML_TEXT" value="true" />
      <option name="HTML" value="true" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="wpa" value="$$$args$ = wp_parse_args( $$$source$, array(&#10;&#9;$key$ =&gt; $value$,&#10;) );" description="wp_parse_args" toReformat="true" toShortenFQNames="true">
    <variable name="args" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="source" expression="args" defaultValue="" alwaysStopAt="true" />
    <variable name="key" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="value" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="false" />
      <option name="HTML" value="false" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="af" value="add_filter( '$hook$', '$callback$' );&#10;$END$" description="add_filter" toReformat="false" toShortenFQNames="true">
    <variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="callback" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="false" />
      <option name="HTML" value="false" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="__" value="__( $SELECTION$, '$textdomain$' )" description="__" toReformat="false" toShortenFQNames="true">
    <variable name="textdomain" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="true" />
      <option name="HTML" value="true" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="aafu" value="add_action( '$hook$', function () {&#10;&#9;$END$&#10;} );" description="add_action &gt; closure" toReformat="false" toShortenFQNames="true">
    <variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="HTML_TEXT" value="false" />
      <option name="HTML" value="false" />
      <option name="XSL_TEXT" value="false" />
      <option name="XML" value="false" />
      <option name="SQL" value="false" />
      <option name="JSP" value="false" />
      <option name="CSS_PROPERTY_VALUE" value="false" />
      <option name="CSS_DECLARATION_BLOCK" value="false" />
      <option name="CSS_RULESET_LIST" value="false" />
      <option name="CSS" value="false" />
      <option name="CUCUMBER_FEATURE_FILE" value="false" />
      <option name="JAVA_SCRIPT" value="false" />
      <option name="TypeScript" value="false" />
      <option name="HAML" value="false" />
      <option name="PHP" value="true" />
      <option name="OTHER" value="false" />
    </context>
  </template>
  <template name="rpt" value="register_post_type( '$SLUG$', array(&#10;&#9;'description'          =&gt; '$DESCRIPTION$',&#10;&#9;'labels'               =&gt; array(&#10;&#9;&#9;'name'               =&gt; _x( '$PLURAL$', 'post type general name', '$DOMAIN$' ),&#10;&#9;&#9;'singular_name'      =&gt; _x( '$SINGULAR$', 'post type singular name', '$DOMAIN$' ),&#10;&#9;&#9;'menu_name'          =&gt; _x( '$PLURAL$', 'admin menu', '$DOMAIN$' ),&#10;&#9;&#9;'name_admin_bar'     =&gt; _x( '$SINGULAR$', 'add new $SLUG$ on admin bar', '$DOMAIN$' ),&#10;&#9;&#9;'add_new'            =&gt; _x( 'Add New', 'post_type', '$DOMAIN$' ),&#10;&#9;&#9;'add_new_item'       =&gt; __( 'Add New $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'edit_item'          =&gt; __( 'Edit $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'new_item'           =&gt; __( 'New $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'view_item'          =&gt; __( 'View $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'search_items'       =&gt; __( 'Search $PLURAL$', '$DOMAIN$' ),&#10;&#9;&#9;'not_found'          =&gt; __( 'No $PLURALLOWERCASE$ found.', '$DOMAIN$' ),&#10;&#9;&#9;'not_found_in_trash' =&gt; __( 'No $PLURALLOWERCASE$ found in Trash.', '$DOMAIN$' ),&#10;&#9;&#9;'parent_item_colon'  =&gt; __( 'Parent $SINGULAR$:', '$DOMAIN$' ),&#10;&#9;&#9;'all_items'          =&gt; __( 'All $PLURAL$', '$DOMAIN$' ),&#10;&#9;),&#10;&#9;'public'               =&gt; $PUBLIC$,&#10;&#9;'hierarchical'         =&gt; $HIERARCHICAL$,&#10;&#9;'exclude_from_search'  =&gt; $NOSEARCH$,&#10;&#9;'publicly_queryable'   =&gt; $QUERYABLE$,&#10;&#9;'show_ui'              =&gt; $UI$,&#10;&#9;'show_in_menu'         =&gt; $MENU$,&#10;&#9;'show_in_nav_menus'    =&gt; $NAVMENU$,&#10;&#9;'show_in_admin_bar'    =&gt; $ADMINBAR$,&#10;&#9;'menu_position'        =&gt; $MENUPOS$,&#10;&#9;'menu_icon'            =&gt; $ICON$,&#10;&#9;'capability_type'      =&gt; '$CAPABILITY$',&#10;&#9;'capabilities'         =&gt; array(),&#10;&#9;'map_meta_cap'         =&gt; null,&#10;&#9;'supports'             =&gt; array( 'title', 'editor' ),&#10;&#9;'register_meta_box_cb' =&gt; $METABOX$,&#10;&#9;'taxonomies'           =&gt; array(),&#10;&#9;'has_archive'          =&gt; $ARCHIVE$,&#10;&#9;'rewrite'              =&gt; array(&#10;&#9;&#9;'slug'       =&gt; '$SLUG$',&#10;&#9;&#9;'with_front' =&gt; $WITHFRONT$,&#10;&#9;&#9;'feeds'      =&gt; $FEEDS$,&#10;&#9;&#9;'pages'      =&gt; $PAGES$,&#10;&#9;),&#10;&#9;'query_var'            =&gt; $QUERYVAR$,&#10;&#9;'can_export'           =&gt; $EXPORT$,&#10;) );&#10;$END$" description="register_post_type" toReformat="true" toShortenFQNames="true">
    <variable name="SLUG" expression="" defaultValue="&quot;post-type&quot;" alwaysStopAt="true" />
    <variable name="DESCRIPTION" expression="" defaultValue="&quot;&quot;" alwaysStopAt="true" />
    <variable name="PLURAL" expression="" defaultValue="&quot;Posts&quot;" alwaysStopAt="true" />
    <variable name="SINGULAR" expression="" defaultValue="&quot;Post&quot;" alwaysStopAt="true" />
    <variable name="DOMAIN" expression="" defaultValue="&quot;text-domain&quot;" alwaysStopAt="true" />
    <variable name="PLURALLOWERCASE" expression="decapitalize(PLURAL)" defaultValue="" alwaysStopAt="false" />
    <variable name="PUBLIC" expression="enum(&quot;false&quot;, &quot;true&quot;)" defaultValue="&quot;false&quot;" alwaysStopAt="true" />
    <variable name="HIERARCHICAL" expression="enum(&quot;false&quot;, &quot;true&quot;)" defaultValue="&quot;false&quot;" alwaysStopAt="true" />
    <variable name="NOSEARCH" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="&quot;true&quot;" alwaysStopAt="true" />
    <variable name="QUERYABLE" expression="" defaultValue="PUBLIC" alwaysStopAt="false" />
    <variable name="UI" expression="" defaultValue="PUBLIC" alwaysStopAt="false" />
    <variable name="MENU" expression="" defaultValue="UI" alwaysStopAt="false" />
    <variable name="NAVMENU" expression="" defaultValue="PUBLIC" alwaysStopAt="false" />
    <variable name="ADMINBAR" expression="" defaultValue="MENU" alwaysStopAt="false" />
    <variable name="MENUPOS" expression="enum(&quot;null&quot;,&quot;5&quot;,&quot;10&quot;,&quot;15&quot;,&quot;20&quot;,&quot;25&quot;,&quot;60&quot;,&quot;65&quot;,&quot;70&quot;,&quot;75&quot;,&quot;80&quot;,&quot;100&quot;)" defaultValue="null" alwaysStopAt="true" />
    <variable name="ICON" expression="" defaultValue="&quot;null&quot;" alwaysStopAt="true" />
    <variable name="CAPABILITY" expression="" defaultValue="&quot;post&quot;" alwaysStopAt="true" />
    <variable name="METABOX" expression="" defaultValue="&quot;null&quot;" alwaysStopAt="true" />
    <variable name="ARCHIVE" expression="" defaultValue="&quot;false&quot;" alwaysStopAt="true" />
    <variable name="WITHFRONT" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="&quot;true&quot;" alwaysStopAt="true" />
    <variable name="FEEDS" expression="" defaultValue="ARCHIVE" alwaysStopAt="false" />
    <variable name="PAGES" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="&quot;true&quot;" alwaysStopAt="true" />
    <variable name="QUERYVAR" expression="" defaultValue="&quot;true&quot;" alwaysStopAt="true" />
    <variable name="EXPORT" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="PHP" value="true" />
    </context>
  </template>
  <template name="rt" value="register_taxonomy( '$SLUG$', array($OBJECT$), array(&#10;&#9;'description'       =&gt; '$DESCRIPTION$',&#10;&#9;'labels'            =&gt; array(&#10;&#9;&#9;'name'                       =&gt; _x( '$PLURAL$', 'taxonomy general name', '$DOMAIN$' ),&#10;&#9;&#9;'singular_name'              =&gt; _x( '$SINGULAR$', 'taxonomy singular name', '$DOMAIN$' ),&#10;&#9;&#9;'search_items'               =&gt; __( 'Search $PLURAL$', '$DOMAIN$' ),&#10;&#9;&#9;'popular_items'              =&gt; __( 'Popular $PLURAL$', '$DOMAIN$' ),&#10;&#9;&#9;'all_items'                  =&gt; __( 'All $PLURAL$', '$DOMAIN$' ),&#10;&#9;&#9;'parent_item'                =&gt; __( 'Parent $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'parent_item_colon'          =&gt; __( 'Parent $SINGULAR$:', '$DOMAIN$' ),&#10;&#9;&#9;'edit_item'                  =&gt; __( 'Edit $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'view_item'                  =&gt; __( 'View $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'update_item'                =&gt; __( 'Update $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'add_new_item'               =&gt; __( 'Add New $SINGULAR$', '$DOMAIN$' ),&#10;&#9;&#9;'new_item_name'              =&gt; __( 'New $SINGULAR$ Name', '$DOMAIN$' ),&#10;&#9;&#9;'separate_items_with_commas' =&gt; __( 'Separate $PLURALLOWERCASE$ with commas', '$DOMAIN$' ),&#10;&#9;&#9;'add_or_remove_items'        =&gt; __( 'Add or remove $PLURALLOWERCASE$', '$DOMAIN$' ),&#10;&#9;&#9;'choose_from_most_used'      =&gt; __( 'Choose from the most used $PLURALLOWERCASE$', '$DOMAIN$' ),&#10;&#9;&#9;'not_found'                  =&gt; __( 'No $PLURALLOWERCASE$ found.', '$DOMAIN$' ),&#10;&#9;),&#10;&#9;'public'            =&gt; $PUBLIC$,&#10;&#9;'show_ui'           =&gt; $UI$,&#10;&#9;'show_in_nav_menus' =&gt; $MENU$,&#10;&#9;'show_tagcloud'     =&gt; $TAGCLOUD$,&#10;&#9;'meta_box_cb'       =&gt; $METABOX$,&#10;&#9;'show_admin_column' =&gt; $ADMINCOLUMN$,&#10;&#9;'hierarchical'      =&gt; $HIERARCHICAL$,&#10;&#9;'query_var'         =&gt; '$QUERYVAR$',&#10;&#9;'rewrite'           =&gt; array(&#10;&#9;&#9;'slug'         =&gt; '$REWRITESLUG$',&#10;&#9;&#9;'with_front'   =&gt; $REWRITEFRONT$,&#10;&#9;&#9;'hierarchical' =&gt; $REWRITEHIERARCHICAL$,&#10;&#9;),&#10;&#9;'capabilities'      =&gt; array(),&#10;) );" description="register_taxonomy" toReformat="true" toShortenFQNames="true">
    <variable name="SLUG" expression="" defaultValue="&quot;taxonomy&quot;" alwaysStopAt="true" />
    <variable name="OBJECT" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="DESCRIPTION" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="PLURAL" expression="" defaultValue="&quot;Tags&quot;" alwaysStopAt="true" />
    <variable name="SINGULAR" expression="" defaultValue="&quot;Tag&quot;" alwaysStopAt="true" />
    <variable name="DOMAIN" expression="" defaultValue="&quot;text-domain&quot;" alwaysStopAt="true" />
    <variable name="PLURALLOWERCASE" expression="decapitalize(PLURAL)" defaultValue="" alwaysStopAt="false" />
    <variable name="PUBLIC" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="&quot;true&quot;" alwaysStopAt="true" />
    <variable name="UI" expression="" defaultValue="PUBLIC" alwaysStopAt="false" />
    <variable name="MENU" expression="" defaultValue="PUBLIC" alwaysStopAt="false" />
    <variable name="TAGCLOUD" expression="" defaultValue="UI" alwaysStopAt="false" />
    <variable name="METABOX" expression="" defaultValue="&quot;null&quot;" alwaysStopAt="true" />
    <variable name="ADMINCOLUMN" expression="enum(&quot;false&quot;,&quot;true&quot;)" defaultValue="false" alwaysStopAt="true" />
    <variable name="HIERARCHICAL" expression="enum(&quot;false&quot;,&quot;true&quot;)" defaultValue="false" alwaysStopAt="true" />
    <variable name="QUERYVAR" expression="" defaultValue="SLUG" alwaysStopAt="true" />
    <variable name="REWRITESLUG" expression="" defaultValue="SLUG" alwaysStopAt="true" />
    <variable name="REWRITEFRONT" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="true" alwaysStopAt="true" />
    <variable name="REWRITEHIERARCHICAL" expression="enum(&quot;true&quot;,&quot;false&quot;)" defaultValue="true" alwaysStopAt="true" />
    <context>
      <option name="PHP" value="true" />
    </context>
  </template>
</templateSet>

以上是关于xml 用于PhpStorm的WordPress实时模板的主要内容,如果未能解决你的问题,请参考以下文章

PHP的93个WordPress插件有后门

PhpStorm 8.0.3中文版

xml PHPStorm IDE的代码样式

xml Webstorm / PHPStorm的Keystone代码样式方案

xml 我目前的Magento 2 PHPStorm文件模板(2016年2月)

phpstorm psr2样式.xml