Strip_tags在get_the_content中不起作用

时间:2016-06-03 22:15:47

标签: php wordpress wordpress-plugin strip-tags

我正在尝试制作一个wordpress插件,但没有工作,也不知道可能是什么。该插件应按get_the_content列出帖子,但格式化。

<?php
register_activation_hook('__FILE__', 'texto');
add_filter ('the_content', 'texto');
   function texto ($text){
      $text = get_the_content( '' );
      $text = apply_filters( 'the_content', $text );
     $text = strip_tags( $text, '<p></br>' );
     return  $text;
    };

?>

这不起作用。如果$text = apply_filters ('the_content', $ text);帖子没有格式化,则$text = apply_filters ('the_content', $ text);博客无法加载。

1 个答案:

答案 0 :(得分:0)

您必须删除class CheckOnOff extends React.Component { constructor() { super(); this.state = { checked: false } this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState({checked: !this.state.checked}); this.props.handleChange(this.state.checked); } render() { const text = this.state.checked ? 'On' : 'Off'; return ( <div> <input type="checkbox" className="on-off-switch" id={this.props.id}></input> <label htmlFor={this.props.id} onClick={this.handleClick} /> <span>{text}</span> </div> ) } }; const Parent = () => { const handleChange = (name, isChecked) => { console.log(name, isChecked); } return ( <div id="settings"> <ul> <li> <p>Auto Sleep: is turned (text from child instance) </p> <CheckOnOff id="auto_sleep" handleChange={handleChange.bind(this, 'checkBox1')}/> </li> <li> <p>Auto Light: is turned (text from child instance) </p> <CheckOnOff id="auto_light" handleChange={handleChange.bind(this, 'checkBox2')}/> </li> </ul> </div> ); } ReactDOM.render( <Parent />, document.getElementById('container') ); 周围的单引号才能解决问题。在您的情况下,文件名未正确解析。

请参阅此链接https://codex.wordpress.org/Function_Reference/register_activation_hook