22 января 2008 ~ 3206 Комментариев

Улучшаем работу с wordpress

wordpress

Прошу прощения за день простоя(луч поноса джино.ру).

Сегодня Я хочу рассказать Вам как облегчить себе работу с популярным у блогеров cms wordpress.

Всегда удобнее иметь самые используемые функции у себя под рукой, для этого я создал себе дополнительный блок, который виден только для меня(администратора).

admin

Такой блок делается с помощью стандартной функции wordpress — current_user_can(), которая решает показывать или не показывать данные пользователю в зависимости от его прав на блоге.

Права пользоватей:

  • Подписчик : level_0
  • Участник: level_1
  • Автор: level_2
  • Редактор: level_3 - level_7
  • Администратор: level_8 - level_10

К примеру, для показа блока только для администратора используем функцию следующим образом:

<?php if (current_user_can('level_10')){ ?>
<ul class="admin_box">
    <?php wp_register(); ?>
    <li><a href="<?php echo get_settings('home'); ?>/wp-admin/post-new.php">Создать новую запись</a></li>
    <li><a href="<?php echo get_settings('home'); ?>/wp-admin/page-new.php">Создать новую станицу</a></li>
    <li><a href="<?php echo get_settings('home'); ?>/wp-admin/options-general.php">Настройки</a></li>
    <li><?php wp_loginout(); ?></li>
</ul>
<?php }?>

Lean on Me divx

Кроме того эту функцию можно использовать и наоборот, для скрытия ненужных блоков, которые нужны для пользователя, но не для администратора.

К примеру:

<?php if (!current_user_can('level_10')){ ?>
    /* Этот блок будет отображатся для всех кроме администратора */
<?php }?>

Можно найти еще множество способов для применения этого приема, но лучше всего готовить это с функциями is_single(), is_page(), is_category() и другими :-)

Всем удачного дня! В следующий раз расскажу как сделать удобное комментирование, как у меня в блоге.

3206 Комментариев для “Улучшаем работу с wordpress”

  1. Владимир Игонин 22 мая 2008 at 13:48 Permalink

    Спасибо, я только начинаю разбираться с WordPress, и такие «маленькие хитрости» очень кстати.

  2. Юра 22 мая 2008 at 14:42 Permalink

    спасибо! тоже интересуюсь этой платформой. цикл статей про вордпресс не помешает

  3. FanToM 0T F_1M 22 мая 2008 at 18:09 Permalink

    Спасибо!! Сегодня обязательно попробую!!!

  4. Kapishin 23 мая 2008 at 2:10 Permalink

    Там ошибка, надо вместо «Админ есть — бог» написать «Админ — бог» или «Админ есть бог» :)

  5. dez 23 мая 2008 at 5:03 Permalink

    Ага, статеек по настройке WP как то маловато.
    Кстати вопрос, а что означает(в чём смысл) пункт «Произвольные поля» при доваблении новости?

  6. Я собственной персоной 23 мая 2008 at 12:32 Permalink

    Ага, статеек по настройке WP как то маловато.
    Кстати вопрос, а что означает(в чём смысл) пункт «Произвольные поля» при доваблении новости?

    Да знаю, очень интересная вещь на самом деле, Максим(maxsite.org) как то писал по этому поводу. Думаю и мне стоит как-нибудь об этом написать :-)

    Там ошибка, надо вместо «Админ есть — бог» написать «Админ — бог» или «Админ есть бог» :)

    Да ладно, эту ошибку вижу только Я, и меня она вполне устраивает :-)

  7. Алексей 30 мая 2008 at 21:47 Permalink

    Спасибо, как раз то что я искал :)

  8. mila 27 июня 2008 at 22:03 Permalink

    Спасибо за подсказку. Полезно.
    Только как ее реализовать?

    Куда вставить код?
    Подскажите уж и это для совсем начинающих.

  9. Я собственной персоной 27 июня 2008 at 23:14 Permalink

    Спасибо за подсказку. Полезно.
    Только как ее реализовать?

    Куда вставить код?
    Подскажите уж и это для совсем начинающих.

    Код вставляется в нужное Вам место в нужной Вам теме оформления.

  10. mila 28 июня 2008 at 0:11 Permalink

    Вставила.
    На странице ничего не появилось.

    Что я делаю не так?
    Пожалуйста, расскажите по шагам.

  11. Я собственной персоной 28 июня 2008 at 12:12 Permalink

    Вставила.
    На странице ничего не появилось.

    Что я делаю не так?
    Пожалуйста, расскажите по шагам.

    Если Вы вставили первый код, то у Вас должно появится меню, которое видно только для Вас(админисратора).

  12. mila 28 июня 2008 at 16:32 Permalink

    Спасибо, Разобралась

  13. Treneroks 11 августа 2008 at 2:00 Permalink

    Отличная статья.
    Было очень интересно читать.
    Спасибо.

  14. Костян 17 ноября 2008 at 1:26 Permalink

    Поди второй пункт в админке самый кликабельный? )))

  15. Саня 11 марта 2009 at 1:04 Permalink

    хм, прикольно

  16. Dovich 9 сентября 2009 at 0:51 Permalink

    Хорошая штука, но расскажи несведущему – куда ставить пхп код, в sidebar.php?

  17. Kseniya 11 марта 2010 at 2:57 Permalink

    Получилось просто и понятно. Спасибо!

  18. Максим 4 октября 2011 at 12:36 Permalink

    Информация полезная, использовал для скрытия выбора редактора в профиле. Жаль что после обновления все переделывать приходится.

  19. Watch TV On A PC 25 февраля 2012 at 18:08 Permalink

    the plot of land lines are very mundane.

  20. Franklyn Hollo 26 февраля 2012 at 4:28 Permalink

    I simply want to mention I’m newbie to blogs and absolutely liked your website. Very likely I’m planning to bookmark your blog post . You really come with fantastic posts. Appreciate it for sharing your website page.

  21. Sacha 29 февраля 2012 at 7:04 Permalink

    I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…

  22. Bradley 29 февраля 2012 at 7:07 Permalink

    Your place is valueble for me. Thanks!…

  23. Shenika 29 февраля 2012 at 7:32 Permalink

    An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers

  24. Owen 29 февраля 2012 at 7:44 Permalink

    Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.

  25. Nixon 29 февраля 2012 at 7:54 Permalink

    Excellent read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thanks for lunch!

  26. Esparza 29 февраля 2012 at 7:55 Permalink

    Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you helped me.

  27. Ward 29 февраля 2012 at 8:28 Permalink

    Do you mind if I quote a few of your posts as long as I provide credit and sources back to your webpage? My blog is in the exact same niche as yours and my visitors would genuinely benefit from a lot of the information you provide here. Please let me know if this ok with you. Thank you!

  28. Ressie 29 февраля 2012 at 8:31 Permalink

    Excellent read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thanks for lunch!

  29. Hassie 29 февраля 2012 at 10:03 Permalink

    An impressive share, I simply given this onto a colleague who was doing a little bit evaluation on this. And he in truth bought me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If potential, as you turn into experience, would you thoughts updating your weblog with extra details? It is highly helpful for me. Huge thumb up for this weblog submit!

  30. maleextra review 29 февраля 2012 at 11:39 Permalink

    Aren’t getting Scamed buying Male Extra

  31. male extra reviews 29 февраля 2012 at 12:21 Permalink

    Where you should buy Male Extra

  32. Mira Minari 29 февраля 2012 at 15:19 Permalink

    Greatest slim weight patch,,Best slimweight patch,review article of the slim weight patch ,2012 slimweight patch review ,slim weight patchhottestreview,

  33. scrapebox fiverr 29 февраля 2012 at 17:31 Permalink

    I’m really loving the theme/design of your internet site. Do you ever run into any browser compatibility difficulties? A number of my weblog readers have complained about my web site not operating correctly in Explorer but looks wonderful in Opera. Do you’ve got any solutions to assist fix this issue?

  34. Buy xrumer list 29 февраля 2012 at 18:33 Permalink

    Oh my goodness! an amazing write-up dude. A lot of thanks Even so My business is experiencing trouble with ur rss . Do not know why Struggle to sign up to it. Can there be everyone acquiring identical rss dilemma? Anyone who knows kindly respond. Thnkx

  35. scrapebox proxies 29 февраля 2012 at 18:38 Permalink

    I view something genuinely unique in this web site .

  36. ceramic watches 29 февраля 2012 at 19:43 Permalink

    Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile Thus let me rephrase that: Thanks for lunch! «They may forget what you said, but they will never forget how you made them feel.» by Carl W. Buechner.

  37. montre gps 29 февраля 2012 at 19:49 Permalink

    I like this blog very much so much excellent information. «The worst solitude is to be destitute of sincere friendship.» by Francis Bacon.

  38. disque dur ssd 29 февраля 2012 at 21:14 Permalink

    I like this web site very much, Its a rattling nice position to read and get info. «Youth is a wonderful thing. What a crime to waste it on children.» by George Bernard Shaw.

  39. camescopehd 29 февраля 2012 at 22:20 Permalink

    I like this internet site because so much utile material on here : D.

  40. leash training a dog 29 февраля 2012 at 23:40 Permalink

    Do y0u mind iff I qu0te a few of your articles as long as I provide credit and sources back to your website? My website is in the exact same niche as yours and my visitors would genuinely benefit from some of the information you provide here. Please let me know if this okay with you. Thank you

  41. velo enfant 29 февраля 2012 at 23:59 Permalink

    I really appreciate this post. I’ve been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thank you again!

  42. compensation consulting firms 1 марта 2012 at 1:47 Permalink

    Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just extremely magnificent. I actually like what you have acquired here, really like what you’re stating and the way in which you say it. You make it enjoyable and you still take care of to keep it wise. I cant wait to read far more from you. This is actually a tremendous site.

  43. sterling insurance 1 марта 2012 at 1:51 Permalink

    Hello there, I found your site by way of Google at the same time as searching for a related topic, your site came up, it seems great. I’ve bookmarked it in my google bookmarks.

  44. atlanta seo 1 марта 2012 at 1:56 Permalink

    You really make it appear really easy along with your presentation however I to find this matter to be really something that I believe I might never understand. It kind of feels too complicated and extremely extensive for me. I’m looking forward in your subsequent publish, I¡¦ll try to get the dangle of it!

  45. Rollins 1 марта 2012 at 2:04 Permalink

    Thanks for another informative site. Where else could I get that kind of information written in such an ideal way? I’ve a project that I am just now working on, and I’ve been on the look out for such information.

  46. Mooney 1 марта 2012 at 2:15 Permalink

    There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game. Both boys and girls feel the impact of just a moment’s pleasure, for the rest of their lives.

  47. Marylynn 1 марта 2012 at 2:17 Permalink

    Just the article I was hoping to see! Thanks! I discovered your blog site site online and check a number of your early on posts. Keep up the really good operate. I recently additional increase RSS feed to help my Yahoo News Viewer. Seeking forward to reading extra from you down the line!…

  48. Skinner 1 марта 2012 at 2:22 Permalink

    An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers

  49. Colene 1 марта 2012 at 2:26 Permalink

    Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you helped me.

  50. Minta 1 марта 2012 at 2:33 Permalink

    An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!


Оставить комментарий