Я редактирую виджеты боковой панели и добавил один для пользователей, которые не вошли в систему или не зарегистрировались. виджет просит пользователей зарегистрироваться или войти в систему, и я хочу добавить случайную причину (цитату) о том, почему они должны присоединиться, которые будут меняться после каждой перезагрузки страницы.
Я решил использовать «текст» на сайте, который, похоже, не загружает ни один из кодов JavaScript, которые я вводил. Очевидно, он их не читает.
кто-нибудь знает, как я могу это сделать?
Если я использую неправильный вид виджетов, то какой из них будет читать и отображать код JavaScript?
или нет ли этого метода JavaScript?
Спасибо.
Ссылка сайта: ПОЖАЛУЙСТА, ЩЕЛКНИТЕ ЗДЕСЬ
Вы говорите, что вы …
… желая добавить случайную причину (цитату) о том, почему они должны присоединиться, которые будут меняться после каждой перезагрузки страницы
И вы, похоже, пытаетесь это сделать, разместив Javascript в текстовом виджете. Я предполагаю, что это то, что вы подразумеваете под «текстом» на сайте ».
Основываясь на этом описании, вам не нужен Javascript. Вам нужен новый виджет боковой панели.
class Quote_Login extends WP_Widget { /*constructs etc*/ function __construct($id = 'quologin', $descr = 'Quote Login', $opts = array()) { $widget_opts = array(); parent::__construct($id,$descr,$widget_opts); } function widget() { $ar = array( '“Nothing is as easy as it looks.”', '“Everything takes longer than you think.”', '“Anything that can go wrong will go wrong.”', '“If there is a possibility of several things going wrong, the one that will cause the most damage will be the one to go wrong.”', '“If there is a worse time for something to go wrong, it will happen then.”', '“If anything simply cannot go wrong, it will anyway.”', '“If you perceive that there are four possible ways in which a procedure can go wrong, and circumvent these, then a fifth way, unprepared for, will promptly develop.”', '“Left to themselves, things tend to go from bad to worse.”', '“If everything seems to be going well, you have obviously overlooked something.”', '“Nature always sides with the hidden flaw.”', '“Mother nature is a bitch.”', '“It is impossible to make anything foolproof because fools are so ingenious.”', '“Whenever you set out to do something, something else must be done first.”', '“Every solution breeds new problems.”', '“Trust everybody … then cut the cards.”', '“Two wrongs are only the beginning.”', '“If at first you don’t succeed, destroy all evidence that you tried.”', '“To succeed in politics, it is often necessary to rise above your principles.”', '“Exceptions prove the rule … and wreck the budget.”', '“Success always occurs in private, and failure in full view.”', ); $quote = $ar[array_rand($ar,1)]; ?> <p><b>It looks like you haven't logged in or have not yet registered.<br> To receive the most accurate results and member benefits, login below or click register to become a member.</b></p> <center> <form action="wp-login.php" method="LINK"> <b><br><input type="submit" value="LOGIN"><br></b> </form> </center> <p></p> <b><p>Why Become A Member?</p> <form name="random"> <input type="text" value="" size="78" name="random" /> </form> <?php // here is your quote // the curly quotes you apparently want won't work in the form input // but I don't know why you are shoving this into an input anyway echo $quote; ?> <p></p><center> <form action="wp-register.php" method="LINK"><br> <input type="submit" value="REGISTER"><br> </form> </center><p></p> </b><p><b>XCLO</b></p> <?php } } add_action('widgets_init', function() { register_widget("Quote_Login"); } );
Вам нужен только Javascript, если вам нужна котировка для изменения, без перезагрузки страницы.
Я не исправил вашу основную разметку (много), но некоторые вещи поражают меня как нечетные, такие как использование форм для создания того, что по существу является связями, и использование устаревших в HTML4 и неподдерживаемых элементов HTML5, таких как <center>
отсортировал это, установив плагин «HTML JAVASCRIPT ADDER».
Благодарю.