Jump to content
  • 0

Помогите настроить админку плагина


vitaxastifler
 Share

Question

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

Вот к пример так:

http://hostingkartinok.com/show-image.php?id=4fcf08f6500b47e1cae47f59d3b32998

Прошу вас,помогите такое организовать кто делал подобное.

А то я не могу найти в гугле.

Edited by vitaxastifler
Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0
rus да,что то похожее

Я уже написал это...

Вот что я вижу:

http://hostingkartinok.com/show-image.php?id=0d25c84c18c7201b6234520e196f0941

Вот код:

<?php/*Plugin Name: urlPlugin URI: http://vk.com	Description: This is my first plugins for wordpress)Version: 1.0Author: VetalAuthor URI: http://vk.com/id1*//*  Copyright 2014  Vetal (email : jenyay.ilin {at} gmail.com)    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA*/function replace_text_wps($text){    $replace = array(	        'google.com' => '<a href="http://google.com">google.com</a>',		           );    $text = str_replace(array_keys($replace), $replace, $text);    return $text;}add_filter('the_content', 'replace_text_wps');add_filter('the_excerpt', 'replace_text_wps');function pudge_add_admin_pages(){add_options_page('url plugin','URL by Velat', 8, 'urlplugin','pudge_option_page');}function pudge_option_page(){echo "<h2>Настройка URL плагина</h2>";}function pudge_run(){$status_url = get_option('pudge_status_url');}add_action ('admin_menu', 'pudge_add_admin_pages');add_action('init', 'pudge_run');?> 

дальше я не знаю как сделать откл и выкл плагина!

Edited by vitaxastifler
Link to comment
Share on other sites

  • 0

Просто деактивировать плагин не вариант? Нужно ли дублировать функционал?

А вообще, то что ты хочешь - это опции, как уже выше написал rus. Для опций есть новое API: http://codex.wordpress.org/Settings_API

Несколько замороченное, вникать можно долго :) Но после этого сможешь клепать опции как безумный.

  • Like 1
Link to comment
Share on other sites

  • 0

hedgehog огромное спасибо.

Блин реально парни,уже мозг кипит,плагин сделал,а 2-е элементарные кнопки которые будут вкл, выкл плагин не могу сделать

Edited by vitaxastifler
Link to comment
Share on other sites

  • 0

Вот как всё должно было быть.

Простая форм...

Спасибо тем кто хоть чем то пытался помочь.

Тема закрыта.

<?php/*Plugin Name: urlPlugin URI: http://vk.comDescription: This is my first plugins for wordpress)Version: 1.0Author: VetalAuthor URI: http://vk.com/id1*//*  Copyright 2014  Veta    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA*/function pudge_add_admin_pages(){add_options_page('url plugin','google url', 8, 'urlplugin','pudge_option_page');}function pudge_option_page(){echo "<h2>Settings URL plugin</h2>";        if ( isset($_POST['pudge_status_on']) OR isset($_POST['pudge_status_off']) ) {            if ( isset($_POST['pudge_status_on']) ) {                update_option('pudge_status_url', 'on');                echo '<h3>Plugin in activation</h3>';            }            else {                update_option('pudge_status_url', 'off');                echo '<h3>Plugin in deactivation</h3>';            }        }        echo '<form method="POST" >';        echo '<input type="submit" name="pudge_status_on" id="pudge_status_on" value="Enable" />';        echo '<input type="submit" name="pudge_status_off" id="pudge_status_off" value="Disable" />';        echo '</form>';}function replace_text_wps($text){    if ( get_option('pudge_status_url') == 'on' ) {        $replace = array(            'google.com' => '<a href="http://google.com">google.com</a>',        );        $text = str_replace(array_keys($replace), $replace, $text);    }    return $text;}function pudge_run(){$status_url = get_option('pudge_status_url');}add_filter('the_content', 'replace_text_wps');add_action ('admin_menu', 'pudge_add_admin_pages');add_action('init', 'pudge_run');?>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy