Пример #1
0
        function render_meta_box($post, $args)
        {
            // extract args
            extract($args);
            // all variables from the add_meta_box function
            extract($args);
            // all variables from the args argument
            // classes
            $class = 'acf-postbox ' . $field_group['style'];
            $toggle_class = 'acf-postbox-toggle';
            // render fields, or render a replace-me div
            if ($visibility) {
                // load fields
                $fields = acf_get_fields($field_group);
                // render
                if ($field_group['label_placement'] == 'left') {
                    ?>
				<table class="acf-table">
					<tbody>
						<?php 
                    acf_render_fields($this->post_id, $fields, 'tr', $field_group['instruction_placement']);
                    ?>
					</tbody>
				</table>
				<?php 
                } else {
                    acf_render_fields($this->post_id, $fields, 'div', $field_group['instruction_placement']);
                }
            } else {
                // update classes
                $class .= ' acf-hidden';
                $toggle_class .= ' acf-hidden';
                echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
            }
            ?>
		<div class="acf-hidden">
			<script type="text/javascript">
			(function($) {
				
				$('#<?php 
            echo $id;
            ?>
').addClass('<?php 
            echo $class;
            ?>
');
				$('#<?php 
            echo $id;
            ?>
').children('.inside').addClass('acf-fields acf-cf');
				$('#adv-settings label[for="<?php 
            echo $id;
            ?>
-hide"]').addClass('<?php 
            echo $toggle_class;
            ?>
');
				
				<?php 
            if ($field_group['ID'] && acf_current_user_can_admin()) {
                ?>
					$('#<?php 
                echo $id;
                ?>
').children('.hndle').append('<a href="<?php 
                echo admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
                ?>
" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="<?php 
                _e('Edit field group', 'acf');
                ?>
"></a>');
				<?php 
            }
            ?>
				
			})(jQuery);	
			</script>
		</div>
		<?php 
        }
Пример #2
0
    function render_meta_box($post, $args)
    {
        // extract args
        extract($args);
        // all variables from the add_meta_box function
        extract($args);
        // all variables from the args argument
        // vars
        $o = array('id' => $id, 'key' => $field_group['key'], 'style' => $field_group['style'], 'edit_url' => '', 'edit_title' => __('Edit field group', 'acf'), 'visibility' => true);
        // vars
        $post_id = acf_get_valid_post_id('options');
        // load fields
        $fields = acf_get_fields($field_group);
        // render
        if ($field_group['label_placement'] == 'left') {
            ?>
			<table class="acf-table">
				<tbody>
					<?php 
            acf_render_fields($post_id, $fields, 'tr', $field_group['instruction_placement']);
            ?>
				</tbody>
			</table>
			<?php 
        } else {
            acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']);
        }
        // edit_url
        if ($field_group['ID'] && acf_current_user_can_admin()) {
            $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
        }
        ?>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
		
	acf.postbox.render(<?php 
        echo json_encode($o);
        ?>
);	

}
</script>
<?php 
    }
Пример #3
0
        function render_meta_box($post, $args)
        {
            // extract args
            extract($args);
            // all variables from the add_meta_box function
            extract($args);
            // all variables from the args argument
            // vars
            $o = array('id' => $id, 'key' => $field_group['key'], 'style' => $field_group['style'], 'label' => $field_group['label_placement'], 'edit_url' => '', 'edit_title' => __('Edit field group', 'acf'), 'visibility' => $visibility);
            // edit_url
            if ($field_group['ID'] && acf_current_user_can_admin()) {
                $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
            }
            // load and render fields
            if ($visibility) {
                // load fields
                $fields = acf_get_fields($field_group);
                // render
                acf_render_fields($this->post_id, $fields, 'div', $field_group['instruction_placement']);
                // render replace-me div
            } else {
                echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
            }
            ?>

<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
		
	acf.postbox.render(<?php 
            echo json_encode($o);
            ?>
);	

}
</script>
<?php 
        }
    function admin_head()
    {
        if (!acf_current_user_can_admin()) {
            return;
        }
        ?>
				<script type="text/javascript">
					jQuery(document).ready(function($){
						var $append = '';
						
						// most fields
						$append = '';
						$append += '<span class="acf-field-details">';
						$append += '<span class="show-field-details dashicons dashicons-info" data-action="show-field-details" onclick="show_field_details(this);"></span>';
						$append += '<span class="acf-field-details-block" style="clear: both; display:none"></span>';
						$append += '</span>';
						$('.acf-field .acf-label label').append($append);
						
						// repeater table
						$append = '';
						$append += '<span class="acf-field-details">';
						$append += '<span class="show-field-details dashicons dashicons-info" data-action="show-field-details" onclick="show_field_details_repeater(this);"></span>';
						$append += '<span class="acf-field-details-block" style="clear: both; display:none"></span>';
						$append += '</span>';
						$('.acf-field-repeater th.acf-th').append($append);
						
						
					});
					function show_field_details(e) {
						//alert(e);
						var $visible = e.style.visibility;
						var $details = e.nextSibling;
						//alert($details);
						if (!$visible) {
							e.style.visibility = 'visible';
							$details.style.display = 'block';
							var $html = $details.innerHTML;
							if (!$html) {
								var $container = e.closest('.acf-field');
								var $key = $container.getAttribute('data-key');
								var $name = $container.getAttribute('data-name');
								$html += '<span>'+$key+'</span>';
								$html += '<span>'+$name+'</span>';
								$details.innerHTML = $html;
							}
						} else {
							e.style.visibility = '';
							$details.style.display = 'none';
						}
					}
					function show_field_details_repeater(e) {
						var $visible = e.style.visibility;
						var $details = e.nextSibling;
						if (!$visible) {
							e.style.visibility = 'visible';
							$details.style.display = 'block';
							var $html = $details.innerHTML;
							if (!$html) {
								var $container = e.closest('.acf-th');
								var $key = $container.getAttribute('data-key');
								var $inputs = jQuery('tr>td[data-key="'+$key+'"]');
								var $input = $inputs[0];
								var $name = $input.getAttribute('data-name');
								$html += '<span>'+$key+'</span>';
								$html += '<span>'+$name+'</span>';
								$details.innerHTML = $html;
							}
						} else {
							e.style.visibility = '';
							$details.style.display = 'none';
						}
					}
				</script>
				<style type="text/css">
					.show-field-details {
						font-weight: normal;
						float: right;
						visibility: hidden;
						color: #AAA;
					}
					.acf-field .acf-label label:hover .show-field-details,
					.acf-field-repeater th.acf-th:hover .show-field-details {
						visibility: visible;
					}
					.acf-field-details-block {
						font-weight: normal;
					}
					.acf-field-details-block>span {
						display: block;
						text-align: right;
					}
				</style>
			<?php 
    }
Пример #5
0
        function edit_comment($comment)
        {
            // vars
            $post_id = "comment_{$comment->comment_ID}";
            // get field groups
            $field_groups = acf_get_field_groups(array('comment' => get_post_type($comment->comment_post_ID)));
            // render
            if (!empty($field_groups)) {
                // render post data
                acf_form_data(array('post_id' => $post_id, 'nonce' => 'comment'));
                foreach ($field_groups as $field_group) {
                    // load fields
                    $fields = acf_get_fields($field_group);
                    // vars
                    $o = array('id' => 'acf-' . $field_group['ID'], 'key' => $field_group['key'], 'label' => $field_group['label_placement'], 'edit_url' => '', 'edit_title' => __('Edit field group', 'acf'));
                    // edit_url
                    if ($field_group['ID'] && acf_current_user_can_admin()) {
                        $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
                    }
                    ?>
				<div id="acf-<?php 
                    echo $field_group['ID'];
                    ?>
" class="stuffbox">
					<h3 class="hndle"><?php 
                    echo $field_group['title'];
                    ?>
</h3>
					<div class="inside">
						<?php 
                    acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']);
                    ?>
						<script type="text/javascript">
						if( typeof acf !== 'undefined' ) {
								
							acf.postbox.render(<?php 
                    echo json_encode($o);
                    ?>
);
						
						}
						</script>
					</div>
				</div>
				<?php 
                }
            }
        }
Пример #6
0
    function postbox_acf($post, $args)
    {
        // extract args
        extract($args);
        // all variables from the add_meta_box function
        extract($args);
        // all variables from the args argument
        // vars
        $o = array('id' => $id, 'key' => $field_group['key'], 'style' => $field_group['style'], 'label' => $field_group['label_placement'], 'edit_url' => '', 'edit_title' => __('Edit field group', 'acf'), 'visibility' => true);
        // get post_id (allow lang modification)
        $post_id = acf_get_valid_post_id($this->page['post_id']);
        // edit_url
        if ($field_group['ID'] && acf_current_user_can_admin()) {
            $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
        }
        // load fields
        $fields = acf_get_fields($field_group);
        // render
        acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']);
        ?>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
		
	acf.postbox.render(<?php 
        echo json_encode($o);
        ?>
);	

}
</script>
<?php 
    }