Home 게시판 커뮤니티 Q&A 이런 플러그인 아시는 분 계세요?

4개 답변, 1 voice Last updated by Avatar of 082net082net 17 years, 5 months 전
  • 익명
    손님
    @
    #2327

    이번에 technorati Link Count Widget의 코드를 플러그인으로 만들어서 블로그에 집어넣다보니
    간단한 코드를 삽입하는 php 함수 하나만 으로 구성된 플러그인을 만드는 게 불편하다는 생각이 들었습니다. 그래서 Add Quick tag 플러그인 형식으로 함수를 입력 저장하고 수정할 수 있는 플러그인이 있으면 어떨까 하는 생각을 했습니다. 간단하게 에디터 태그를 추가하는 식으로 간단한 함수들이 작동하도록 하는 플러그인이죠. php에 문외한이라 가능한 일인지 어쩐지도 모르고 add quick tag플러그인의 소스를 수정해 wp_option table에 입력한 함수를 저장하는 부분까지는 제가 구현했는데 이렇게 저장한 함수가 작동되도록 하려면 어떻게 해야할지 조금 막막합니다.


    <?php
    /*
    Plugin Name: WP-Add Function
    Plugin URI: http://ktc.kunsan.ac.kr/~unfusion/word?p=429
    Description: 워드프레스에 간단한 함수를 삽입할 수 있는 플러그인 입니다.
    Version: 0.1
    Author: unfusion
    Author URI: http://ktc.kunsan.ac.kr/~unfusion/word
    License: GNU
    */

    // SCRIPT INFO ///////////////////////////////////////////////////////////////////////////

    /*
       WP-Addfunction for WordPress
       (C) 2005 Roel Meurders - GNU General Public License

       This WordPress plugin is released under a GNU General Public License. A complete version of this license
       can be found here: http://www.gnu.org/licenses/gpl.txt

       This WordPress plugin has been tested with WordPress 1.5.2;

       This WordPress plugin is released "as is". Without any warranty. The author cannot
       be held responsible for any damage that this script might cause.

    */

    // NO EDITING HERE!!!!! ////////////////////////////////////////////////////////////////

       add_action('admin_menu', 'wpaf_admin_menu');

       function wpaf_admin_menu(){
          add_options_page('WP-Addfunction - Add Function', 'Add Function', 9, basename(__FILE__), 'wpaf_options_page');
       }

       function wpaf_options_page(){
          if ($_POST['wpaf']){
             $buttons = array();
             for ($i = 0; $i < count($_POST['wpaf']['buttons']); $i++){
                $b = $_POST['wpaf']['buttons'][$i];
                if ($b['function'] != '' && $b['description'] != ''){
                   $b['function'] = stripslashes($b['function']);
                   $b['description'] = stripslashes($b['description']);
                   $buttons[] = $b;
                }
             }
             $_POST['wpaf']['buttons'] = $buttons;
             update_option('ufsAddFunction', $_POST['wpaf']);
             $message = '<div class="updated"><p><strong>Function saved.</strong></p></div>';
          }

          $o = get_option('ufsAddFunction');

          echo <<<EOT
          <div class="wrap">
             <h2>WP-Add Function Management</h2>
             {$message}
             <form name="form1" method="post" action="options-general.php?page=wp-addfunction.php">
             <fieldset class="options">
                <legend>Adding or deleting function</legend>
                <p>Fill in the fields below to add or edit the function. Fields with * are compulsary. To delete a function simply empty field.</p>
                <table width="100%" cellspacing="2" cellpadding="5" class="editform">
                   <tr>
                      <th style="text-align: center;">Function Code(s)*</th>
                      <th style="text-align: center;">Description(s)</th>
                   </tr>
    EOT;
          for ($i = 0; $i < count($o['buttons']); $i++){
             $b = $o['buttons'][$i];
             $nr = $i + 1;
             echo <<<EOT
                   <tr valign="top" style="text-align: center;">
                      <td><textarea name="wpaf[buttons][{$i}][function]" rows="2" cols="25" style="width: 95%;">{$b['function']}</textarea></td>
                      <td><textarea name="wpaf[buttons][{$i}][description]" rows="2" cols="25" style="width: 95%;">{$b['description']}</textarea></td>
                   </tr>
    EOT;
          }
          echo <<<EOT
                   <tr valign="top" style="text-align: center;">
                      <td><textarea name="wpaf[buttons][{$i}][function]" rows="2" cols="25" style="width: 95%;"></textarea></td>
                      <td><textarea name="wpaf[buttons][{$i}][description]" rows="2" cols="25" style="width: 95%;"></textarea></td>
                   </tr>
                </table>
             </fieldset>
             <p class="submit">
                <input type="submit" name="Submit" value="Update Options &raquo;" />
             </p>
             </form>
          </div>
    EOT;
       }

          
    ?>

    이게 지금 수정한 소스이고 마지막에 입력한 함수가 작동되도록 하는 부분을 추가하면 될 것 같은데 오늘 너무 놀아버렸네요. 혹시 082 님 좋은 아이디어나 해결책이 떠오르시면 조언 부탁드립니다. … 되는지 안되는지도 모르고 저질러 버렸네요ㅎㅎ

    익명
    손님
    @
    #2328

    addquicktag 플러그인 형식으로 간단한 함수를 추가 편집할 수 있는 플러그인이 있을까요?

    익명
    손님
    @
    #2330

    addquicktag 플러그인 형식으로 간단한 함수를 추가 편집할 수 있는 플러그인이 있을까요?

    Avatar of 082net082net
    Keymaster
    @082net
    #2329

    어… 무슨 말씀이신지를 이해하기 힘듭니다.

    "addquicktag처럼" 까지는 어느정도 감이 잡히는데, 어디에 적용하시려하는지 어떤 용도로 사용하려고 하시는지를 조금 구체적으로 설명해 주세요 🙂

    Avatar of 082net
    Facebook 사용자 모임 그룹 도 함께 운영되고 있으며, 격 주로 미트업과 스터디를 진행하고 있으니 관심 있으신 분들의 많은 참여 바랍니다 🙂
    Avatar of 082net082net
    Keymaster
    @082net
    #2331

    어… 무슨 말씀이신지를 이해하기 힘듭니다.

    "addquicktag처럼" 까지는 어느정도 감이 잡히는데, 어디에 적용하시려하는지 어떤 용도로 사용하려고 하시는지를 조금 구체적으로 설명해 주세요 🙂

    Avatar of 082net
    Facebook 사용자 모임 그룹 도 함께 운영되고 있으며, 격 주로 미트업과 스터디를 진행하고 있으니 관심 있으신 분들의 많은 참여 바랍니다 🙂
5 글 보임 - 1에서 5 까지 (총 5 중에서)
  • 답변은 로그인 후 가능합니다.