Example #1
0
    public function form_options($options)
    {
        global $mf_domain;
        ?>
    <div class="widefat mf_form mf_form_settings">
    <form method="post" action="<?php 
        echo get_option('siteurl');
        ?>
/wp-admin/options-general.php?page=mf_settings&amp;noheader=true">
       <h3><?php 
        _e('General settings of fields', $mf_domain);
        ?>
</h3>
      <?php 
        foreach ($options['general'] as $option) {
            if ($option['type'] == 'text') {
                mf_form_text($option);
            } elseif ($option['type'] == 'checkbox') {
                mf_form_checkbox($option);
            }
        }
        ?>
    <h3><?php 
        _e('Extra', $mf_domain);
        ?>
</h3>
      <?php 
        foreach ($options['extra'] as $option) {
            if ($option['type'] == 'text') {
                mf_form_text($option);
            } elseif ($option['type'] == 'checkbox') {
                mf_form_checkbox($option);
            }
        }
        ?>
      <h3><?php 
        _e('Uninstall Magic Fields', $mf_domain);
        ?>
</h3>
      <input type="text" name="uninstall_magic_field" size="25" /><br />
      <label for="uninstall_magic_field">
        <?php 
        _e('Type <strong>uninstall</strong> into the textbox, click <strong>Update Options</strong>, and all the tables created by this plugin will be deleted', $mf_domain);
        ?>
</label>

    <div class="clear"></div>
      <input type="submit" value="Submit" class="button" >
      </form>
      </div>
    <?php 
    }
Example #2
0
    function form_post_type($data)
    {
        global $mf_domain;
        $supports = array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes');
        print '<div class="wrap">';
        print '<div id="message_post_type" class="error below-h2" style="display:none;"><p></p></div>';
        print '<div id="icon-edit" class="icon32"><br /></div>';
        if (!$data['core']['id']['value']) {
            print '<h2>' . __('Add Post Type', $mf_domain) . '</h2>';
        } else {
            printf("<h2>%s - %s</h2>", __('Edit Post Type'), $data['core']['label']['value']);
        }
        print '</div>';
        ?>
     <form id="addPostType" method="post" action="admin.php?page=mf_dispatcher&init=true&mf_section=mf_posttype&mf_action=save_post_type" class="validate mf_form_admin">

      <!-- Nonces -->
      <?php 
        wp_nonce_field('form_post_type_posttype');
        ?>
      <!-- /Nonces  -->

    <div class="alignleft fixed" id="add_mf_posttype">
	<!-- core -->
	<?php 
        foreach ($data['core'] as $core) {
            ?>
	<?php 
            if ($core['type'] == 'hidden') {
                ?>
	  <?php 
                mf_form_hidden($core);
                ?>
	<?php 
            } elseif ($core['type'] == 'text') {
                ?>
	  <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
	    <?php 
                mf_form_text($core);
                ?>
	  </div>
	<?php 
            }
            ?>
	<?php 
        }
        ?>
	<! / core -->

	<!-- supports -->
	<div class="form-field mf_label_checkbox mf_form">
	  <?php 
        _e('Supports', $mf_domain);
        ?>
	  <?php 
        foreach ($supports as $support) {
            ?>
	    <?php 
            $check = '';
            if (in_array($support, $data['posttype_support'])) {
                $check = 'checked="checked"';
            }
            ?>
	    <p>
	    <input name="mf_posttype[support][<?php 
            echo $support;
            ?>
]" id="posttype-support-<?php 
            echo $support;
            ?>
" value="1" type="checkbox" <?php 
            echo $check;
            ?>
 >
	    <label for="posttype-support-<?php 
            echo $support;
            ?>
"><?php 
            echo preg_replace('/-/', ' ', $support);
            ?>
</label>
	    </p>
	  <?php 
        }
        ?>
	</div>
	<!-- / supports -->

	<!-- taxonomies -->
	<div class="form-field mf_label_checkbox mf_form">
	  <?php 
        _e('Taxonomies', $mf_domain);
        ?>
	  <?php 
        $taxonomies = get_taxonomies(array('public' => true), 'objects');
        ?>
            <?php 
        foreach ($taxonomies as $tax) {
            ?>
      <?php 
            if (!in_array($tax->name, array('nav_menu', 'post_format'))) {
                ?>
	      <?php 
                $check = '';
                if (in_array($tax->name, $data['posttype_taxonomy'])) {
                    $check = 'checked="checked"';
                }
                ?>
	      <p>
		<input name="mf_posttype[taxonomy][<?php 
                echo $tax->name;
                ?>
]" id="posttype-taxonomy-<?php 
                echo $tax->name;
                ?>
" type="checkbox" value="1" <?php 
                echo $check;
                ?>
 >
		<label for="posttype-taxonomy-<?php 
                echo $tax->name;
                ?>
"><?php 
                echo $tax->label;
                ?>
</label>
	      </p>
	    <?php 
            }
            ?>
	  <?php 
        }
        ?>
	</div>
	<!-- / taxonomies -->

	<!-- Submit -->
	<p class="submit">
	  <a style="color:black" href="admin.php?page=mf_dispatcher" class="button">Cancel</a>
	  <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Post type">
	</p>
	<!-- / Submit -->
    </div>

    <div class="widefat mf_form_right stuffbox metabox-holder">
      <h3><?php 
        _e('Options', $mf_domain);
        ?>
</h3>
      <div class="inside  categorydiv">
        <ul id="category-tabs" class="category-tabs options-tabs">
          <li class="tabs">
            <a id="options" href="#" ><?php 
        _e('Advanced Options', $mf_domain);
        ?>
</a>
          </li>
          <li class="">
            <a id="options_label" href="#"><?php 
        _e('Advanced Label', $mf_domain);
        ?>
</a>
          </li>
        </ul>
        <div class="tabs-panel">

          <div class="options">
            <fieldset>
              <legend><?php 
        _e('Advanced Options', $mf_domain);
        ?>
</legend>
              <!-- options -->
              <?php 
        foreach ($data['option'] as $option) {
            ?>
              <div class="form-field mf_label_checkbox mf_form">
                <?php 
            if ($option['type'] == 'text') {
                mf_form_text($option);
            } elseif ($option['type'] == 'checkbox') {
                mf_form_checkbox($option);
            }
            ?>
              </div>
              <?php 
        }
        ?>
              <!-- / options -->
            </fieldset>
          </div>

          <div class="options_label" style="display: none;">
	    <fieldset>
	      <?php 
        mf_form_checkbox($data['suggest_labels']);
        ?>
	    </fieldset>

	    <fieldset>
	      <legend><?php 
        _e('Label Options', $mf_domain);
        ?>
</legend>
	      <!-- labels -->
	      <?php 
        foreach ($data['label'] as $label) {
            ?>
	        <div class="form-field mf_label_checkbox mf_form">
	          <?php 
            mf_form_text($label);
            ?>
	        </div>
	      <?php 
        }
        ?>
              <!-- / labels -->
            </fieldset>
          </div>
        </div>
      </div>
    </div>
     </form>
    <?php 
    }
Example #3
0
    function form_custom_group($data)
    {
        global $mf_domain;
        ?>
    <div class="wrap">
      <div id="message_mf_error" class="error below-h2" style="display:none;"><p></p></div>
      <div id="icon-themes" class="icon32"><br></div>
      <?php 
        if (!$data['core']['id']['value']) {
            ?>
      <h2><?php 
            _e('Create Custom Group', $mf_domain);
            ?>
</h2>
      <?php 
        } else {
            ?>
    <h2><?php 
            _e('Edit Custom Group', $mf_domain);
            ?>
 - <?php 
            echo $data['core']['label']['value'];
            ?>
</h2>
      <?php 
        }
        ?>


     <form id="addCustomGroup" method="post" action="admin.php?page=mf_dispatcher&init=true&mf_section=mf_custom_group&mf_action=save_custom_group" class="validate mf_form_admin">
      <div class="alignleft fixed" style="width: 40%;" id="mf_add_custom_group">
        <?php 
        foreach ($data['core'] as $core) {
            ?>
          <?php 
            if ($core['type'] == 'hidden') {
                ?>
	          <?php 
                mf_form_hidden($core);
                ?>
          <?php 
            } elseif ($core['type'] == 'text') {
                ?>
	          <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_text($core);
                ?>
            </div>
          <?php 
            } elseif ($core['type'] == "select") {
                ?>
            <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_select($core);
                ?>
            </div>
          <?php 
            } elseif ($core['type'] == "checkbox") {
                ?>
            <fieldset>
              <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_checkbox($core);
                ?>
              </div>
            </fieldset>
          <?php 
            }
            ?>
 
        <?php 
        }
        ?>
      	<p class="submit">
      	  <a style="color:black" href="admin.php?page=mf_dispatcher&mf_section=mf_custom_fields&mf_action=fields_list&post_type=<?php 
        echo $data['core']['post_type']['value'];
        ?>
" class="button">Cancel</a>
      	  <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Custom Group">
      	</p>
      </div>
      <div class="widefat mf_form_right stuffbox metabox-holder">
        <h3><?php 
        _e('About group', $mf_domain);
        ?>
</h3>
        <div class="inside">
          <div id="options_field" class="group_side">
            <p><?php 
        _e('A group allows us to group a series of custom fields and to have a better managing of the custom fields', $mf_domain);
        ?>
</p>
            <p><?php 
        _e('The groups have the great usefulness of which it is possible to duplicate, this is, one creates new instance of the group (with all the custom fields that the group contains)', $mf_domain);
        ?>
</p>
            <p><?php 
        _e('Another characteristic of the duplicated groups is that we them can arrange and have a control of which group we want that it show to be first', $mf_domain);
        ?>
</p>
            <p><img src="<?php 
        echo MF_URL;
        ?>
images/admin/group.jpg"/></p>
          </div>
        </div>
      </div>
    </div>
</form>
  <?php 
    }
    /**
     * form
     */
    function form_custom_taxonomy($data)
    {
        global $mf_domain;
        print '<div class="wrap">';
        print '<div id="message_mf_error" class="error below-h2" style="display:none;"><p></p></div>';
        print '<div id="icon-edit" class="icon32"><br /></div>';
        if (!$data['core']['id']['value']) {
            print '<h2>' . __('Add Custom Taxonomy', $mf_domain) . '</h2>';
        } else {
            printf("<h2>%s - %s</h2>", __('Edit Custom Taxonomy'), $data['core']['label']['value']);
        }
        print '</div>';
        ?>
     <form id="addCustomTaxonomy" method="post" action="admin.php?page=mf_dispatcher&init=true&mf_section=mf_custom_taxonomy&mf_action=save_custom_taxonomy" class="validate mf_form_admin">
       
      <?php 
        //nonce
        wp_nonce_field('form_custom_taxonomy_mf_custom_taxonomy');
        ?>

    <div class="alignleft fixed" id="add_mf_custom_taxonomy">
	<!-- core -->
	<?php 
        foreach ($data['core'] as $core) {
            ?>
	<?php 
            if ($core['type'] == 'hidden') {
                ?>
	  <?php 
                mf_form_hidden($core);
                ?>
	<?php 
            } elseif ($core['type'] == 'text') {
                ?>
	  <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
	    <?php 
                mf_form_text($core);
                ?>
	  </div>
	<?php 
            }
            ?>
	<?php 
        }
        ?>
	<!-- / core -->
        
        <!-- post types -->
        <div class="form-field mf_label_checkbox mf_form form_required">
          <?php 
        _e('Post types', $mf_domain);
        ?>
 <span class="required">*</span>
          <?php 
        $post_types = $this->mf_get_post_types();
        ?>
          <?php 
        $i = 1;
        ?>
          <?php 
        foreach ($post_types as $pt) {
            ?>
            <?php 
            if ($pt->name != 'attachment') {
                ?>
              <?php 
                $check = '';
                if (in_array($pt->name, $data['taxonomy']['post_type'])) {
                    $check = 'checked="checked"';
                }
                $val = 'a';
                if ($i == 1) {
                    $val = sprintf("{validate:{required:true,messages:{required:'%s'}}}", __('This Field is required, least one post type', $mf_domain));
                }
                $i++;
                ?>
              <p>
                <input name="mf_custom_taxonomy[post_types][]" id="custom-taxonomy-post-type-<?php 
                echo $pt->name;
                ?>
" type="checkbox" value="<?php 
                echo $pt->name;
                ?>
" <?php 
                echo $check;
                ?>
 class="<?php 
                echo $val;
                ?>
" >
                <label for="custom-taxonomy-post-type-<?php 
                echo $pt->name;
                ?>
"><?php 
                echo $pt->label;
                ?>
</label>
              </p>
            <?php 
            }
            ?>
          <?php 
        }
        ?>
        </div>
        <!-- / post types -->

        <!-- Submit -->
        <p class="submit">
          <a style="color:black" href="admin.php?page=mf_dispatcher" class="button">Cancel</a>
          <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Custom Taxonomy">
        </p>
        <!-- / Submit -->
    </div>
    
    <div class="widefat mf_form_right stuffbox metabox-holder">
      <h3><?php 
        _e('Options', $mf_domain);
        ?>
</h3>
      <div class="inside  categorydiv">
        <ul id="category-tabs" class="category-tabs options-tabs">
          <li class="tabs">
            <a id="options" href="#" ><?php 
        _e('Advanced Options', $mf_domain);
        ?>
</a>
          </li>
          <li class="">
            <a id="options_label" href="#"><?php 
        _e('Advanced Label', $mf_domain);
        ?>
</a>
          </li>
        </ul>
        <div class="tabs-panel">
          <div class="options">
            <fieldset>
              <legend><?php 
        _e('Advanced Options', $mf_domain);
        ?>
</legend>
              <!-- options -->
              <?php 
        foreach ($data['option'] as $option) {
            ?>
              <div class="form-field mf_label_checkbox mf_form">
                <?php 
            if ($option['type'] == 'text') {
                mf_form_text($option);
            } elseif ($option['type'] == 'checkbox') {
                mf_form_checkbox($option);
            }
            ?>
              </div>
              <?php 
        }
        ?>
              <!-- / options -->
            </fieldset>
          </div>
      
          <div class="options_label" style="display: none;">
            <fieldset>
              <?php 
        mf_form_checkbox($data['suggest_labels']);
        ?>
            </fieldset>

            <fieldset>
              <legend><?php 
        _e('Label Options', $mf_domain);
        ?>
</legend>
              <!-- labels -->
              <?php 
        foreach ($data['label'] as $label) {
            ?>
              <div class="form-field mf_label_checkbox mf_form">
                <?php 
            mf_form_text($label);
            ?>
              </div>
              <?php 
        }
        ?>
              <!-- / labels -->
            </fieldset>
          </div>
        </div>
      </div>
  </form>
  <?php 
    }
    function form_custom_field($data)
    {
        global $mf_domain;
        $name_group = '';
        if ($data['core']['custom_group_id']['value']) {
            $group = $this->get_group($data['core']['custom_group_id']['value']);
            $name_group = $group['name'];
        }
        printf('<input type="hidden" id="name_group_slug" value="%s" >', $name_group);
        ?>
    <div class="wrap">
      <div id="message_mf_error" class="error below-h2" style="display:none;"><p></p></div>
      <div id="icon-edit-pages" class="icon32 icon32-posts-page"><br></div>
      <?php 
        if (!$data['core']['id']['value']) {
            ?>
       <h2><?php 
            _e('Create Custom Field', $mf_domain);
            ?>
</h2>
    <?php 
        } else {
            ?>
    <h2><?php 
            _e('Edit Custom Field', $mf_domain);
            echo ' - ' . $data['core']['label']['value'];
            ?>
</h2>
      <?php 
        }
        ?>

     <form id="addCustomField" method="post" action="admin.php?page=mf_dispatcher&init=true&mf_section=mf_custom_fields&mf_action=save_custom_field" class="validate mf_form_admin">
      <div class="alignleft fixed" style="width: 40%;" id="mf_add_custom_field">
        <?php 
        foreach ($data['core'] as $core) {
            ?>
          <?php 
            if ($core['type'] == 'hidden') {
                ?>
                  <?php 
                mf_form_hidden($core);
                ?>
          <?php 
            } elseif ($core['type'] == 'text') {
                ?>
                  <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_text($core);
                ?>
            </div>
          <?php 
            } elseif ($core['type'] == "select") {
                ?>
            <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_select($core);
                ?>
            </div>
            <?php 
            } elseif ($core['type'] == "textarea") {
                ?>
            <div class="form-field mf_form helptext-form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_textarea($core);
                ?>
            </div>
          <?php 
            } elseif ($core['type'] == "checkbox") {
                ?>
            <fieldset>
              <div class="form-field mf_form <?php 
                echo $core['div_class'];
                ?>
">
              <?php 
                mf_form_checkbox($core);
                ?>
              </div>
            </fieldset>
          <?php 
            }
            ?>
        <?php 
        }
        ?>
        <p class="submit">
          <a style="color:black" href="admin.php?page=mf_dispatcher&mf_section=mf_custom_fields&mf_action=fields_list&post_type=<?php 
        echo $data['core']['post_type']['value'];
        ?>
" class="button">Cancel</a>
          <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Custom Field">
        </p>
      </div>
      <div class="widefat mf_form_right stuffbox metabox-holder">
        <h3>Options of field</h3>
        <div class="inside">
        <?php 
        $legend_class = $data['core']['id']['value'] ? sprintf('style="display:none;"') : '';
        ?>
        <div  id="options_field_legend" <?php 
        echo $legend_class;
        ?>
 >
          <p>By default on this box will be displayed a information about custom fields, after the  custom field be selected, this box will be displayed some extra options of the field (if required) or a information about the selected field</p>
        </div>
        <div id="options_field">
           <?php 
        if ($data['core']['id']['value']) {
            $name = sprintf('%s_field', $data['core']['type']['value']);
            $mf_field = new $name();
            $mf_field->get_options($data['option'], $name);
        }
        ?>
        </div>
      </div>
      </div>
    </div>
</form>
  <?php 
    }