static function init()
 {
     // Register each sidebar
     $sidebars = sidebar_generator::get_sidebars();
     if (is_array($sidebars)) {
         global $shortname;
         $sidebarName = get_option($shortname . 'sidebarSettings');
         // get name values
         foreach ($sidebars as $key => $value) {
             $id = $key;
             $name = $value['name'];
             $alias = $value['alias'];
             //$sidebar_class = sidebar_generator::name_to_class($name.$id);
             $sidebar_class = sidebar_generator::name_to_class($alias);
             register_sidebar(array('name' => $name, 'id' => "generated_sidebar-{$id}", 'before_widget' => '<div id="%1$s" class="widget scg_widget ' . $sidebar_class . ' %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="widgetTitle">', 'after_title' => '</h4>'));
         }
     }
 }
    static function admin_page()
    {
        ?>
        <script>
            function remove_sidebar_link(name,num){
                answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
                if(answer){
                    //alert('AJAX REMOVE');
                    remove_sidebar(name,num);
                }else{
                    return false;
                }
            }
            function add_sidebar_link(){
                var sidebar_name = prompt("Sidebar Name:","");
                //alert(sidebar_name);
                add_sidebar(sidebar_name);
            }
        </script>
        <div class="wrap">
            <h2>Sidebars</h2>
            <br />
            <table class="widefat page" id="sbg_table" style="width:600px;">
                <tr>
                    <th>Sidebar Name</th>
                    <th>CSS class</th>
                    <th>Remove</th>
                </tr>
                <?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
                <tr class="<?php 
                echo esc_attr($alt);
                ?>
">
                    <td><?php 
                echo esc_html($sidebar);
                ?>
</td>
                    <td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
                    <td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo esc_js($sidebar);
                ?>
',<?php 
                echo esc_js($cnt + 1);
                ?>
);" title="Remove this sidebar">remove</a></td>
                </tr>
                <?php 
                $cnt++;
            }
        } else {
            ?>
                    <tr>
                        <td colspan="3">No Sidebars defined</td>
                    </tr>
                    <?php 
        }
        ?>
            </table><br /><br />
            <div class="add_sidebar">
                <a href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar" class="button-primary">+ Add New Sidebar</a>

            </div>

        </div>
        <?php 
    }
    public static function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("<?php 
        _e('Are you sure you want to remove', 'Avada');
        ?>
 " + name + "?\n<?php 
        _e('This will remove any widgets you have assigned to this widget section.', 'Avada');
        ?>
");
				if(answer){
					//alert('AJAX REMOVE');
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("<?php 
        _e('Widget Section Name:', 'Avada');
        ?>
","");
				//alert(sidebar_name);
				add_sidebar(sidebar_name);
			}
		</script>
		<div class="wrap">
			<h2>Widget Sections</h2>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th>Widget Section Name</th>
					<th>CSS class</th>
					<th>Remove</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
				<tr class="<?php 
                echo $alt;
                ?>
">
					<td><?php 
                echo $sidebar;
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar;
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="<?php 
                _e('Remove this Widget Section', 'Avada');
                ?>
">remove</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="3"><?php 
            _e('No Widget Sections defined.', 'Avada');
            ?>
</td>
					</tr>
					<?php 
        }
        ?>
			</table><br /><br />
			<div class="add_sidebar">
				<a href="javascript:void(0);" onclick="return add_sidebar_link()" title="<?php 
        _e('Add New Widget Section', 'Avada');
        ?>
" class="button-primary"><?php 
        _e('Add New Widget Section', 'Avada');
        ?>
</a>

			</div>

		</div>
		<?php 
    }
    static function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link() {
				jQuery('#sbg_table tr:last').after('<tr><td><b>Sidebar Name:</b><br /><input type="text" name="sidebar_name" id="sidebar_name" /></td><td><b>Sidebar Type:</b><br /><select name="sidebar_type" id="sidebar_type"><option value="normal">Normal</option></select></td><td></td><td style="vertical-align: middle;"><a href="javascript:void(0);" onclick="add_sidebar(jQuery(\'#sidebar_name\').val(), jQuery(\'#sidebar_type\').val());" title="Remove this sidebar">save</a></td></tr>');
				jQuery('.add-sidebar-button').attr("disabled", "disabled");
			}
		</script>
		<div class="wrap">
			<h2>Manage Sidebars</h2>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th>Sidebar Name</th>
					<th>Sidebar Type</th>
					<th>CSS class</th>
					<th>Remove</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
						<tr class="<?php 
                echo $alt;
                ?>
">
							<td><?php 
                echo $sidebar['name'];
                ?>
</td>
							<td><?php 
                echo $sidebar['type'];
                ?>
</td>
							<td><?php 
                echo sidebar_generator::name_to_class($sidebar['name']);
                ?>
</td>
							<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar['name'];
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="Remove this sidebar">remove</a></td>
						</tr>
						<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="4">No Sidebars defined</td>
					</tr>
					<?php 
        }
        ?>
			</table><br /><br />
			<div class="add_sidebar">
				<button href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar" class="button-primary add-sidebar-button">+ Add New Sidebar</button>
			</div>
		</div>
		<?php 
    }
Ejemplo n.º 5
0
    public static function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					//alert('AJAX REMOVE');
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("Sidebar Name:","");
				//alert(sidebar_name);
				add_sidebar(sidebar_name);
			}
		</script>
		<div class="wrap">
			<h2><?php 
        _e('Custom Sidebars', 'framework');
        ?>
</h2>
			<br />
<!-- 			<div class="add_sidebar">
				<a href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar"><?php 
        _e('+ Add Sidebar', 'framework');
        ?>
</a>
			</div> -->
			<h3><?php 
        __('This function is deprecated please remove all of your custom sidebars from here and build it from custom sidebar box in the widgets page', 'theme');
        ?>
</h3>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th><?php 
        _e('Name', 'framework');
        ?>
</th>
					<th><?php 
        _e('CSS class', 'framework');
        ?>
</th>
					<th><?php 
        _e('Remove', 'framework');
        ?>
</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
				<tr class="<?php 
                echo $alt;
                ?>
">
					<td><?php 
                echo $sidebar;
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar;
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="Remove this sidebar">remove</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="3"><?php 
            _e('No Sidebars defined', 'framework');
            ?>
</td>
					</tr>
					<?php 
        }
        ?>
			</table>
			<br /><br />
		</div>
		<?php 
    }
Ejemplo n.º 6
0
    static function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("<?php 
        printf(__('Are you sure you want to remove %s?\\nThis will remove any widgets you have assigned to this sidebar.', 'cumulo'), '" + name + "');
        ?>
");
				if(answer){
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("<?php 
        echo esc_html__('Sidebar Name', 'cumulo');
        ?>
:","");
				if ( sidebar_name != null )
					add_sidebar(sidebar_name);
			}
		</script>
		<div class="wrap">
			<h2><?php 
        echo __('Sidebar Generator', 'cumulo');
        ?>
</h2>
			<p>
				<?php 
        echo __('The sidebar name is for your use only. It will not be visible to any of your visitors.', 'cumulo');
        ?>
				<?php 
        echo __('A CSS class is assigned to each of your sidebar, use this styling to customize the sidebars.', 'cumulo');
        ?>
			</p>
			<br />
			<div class="add_sidebar">
				<a href="javascript:void(0);" class='button' onclick="return add_sidebar_link()" title="Add a sidebar">+ <?php 
        echo __('Add Sidebar', 'cumulo');
        ?>
</a>
			</div>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th><?php 
        echo __('Name', 'cumulo');
        ?>
</th>
					<th><?php 
        echo __('CSS class', 'cumulo');
        ?>
</th>
					<th><?php 
        echo __('Remove', 'cumulo');
        ?>
</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
				<tr class="<?php 
                echo esc_attr($alt);
                ?>
">
					<td><?php 
                echo esc_html($sidebar);
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo esc_attr($sidebar);
                ?>
',<?php 
                echo intval($cnt) + 1;
                ?>
);" title="<?php 
                echo __('Remove this sidebar', 'cumulo');
                ?>
">remove</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="3"><?php 
            echo __('No Sidebars defined', 'cumulo');
            ?>
</td>
					</tr>
					<?php 
        }
        ?>
			</table>
		</div>
		<?php 
    }
    function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					//alert('AJAX REMOVE');
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("Sidebar Name:","");
				//alert(sidebar_name);
				add_sidebar(sidebar_name);
			}
		</script>
		<div class="wrap">
			<h2>Sidebar Generator</h2>
			<p>
				The sidebar name is for your use only. It will not be visible to any of your visitors. 
				A CSS class is assigned to each of your sidebar, use this styling to customize the sidebars.
			</p>
			<br />
			<div class="add_sidebar">
				<a href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar">+ Add Sidebar</a>
			</div>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th>Name</th>
					<th>CSS class</th>
					<th>Remove</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
				<tr class="<?php 
                echo $alt;
                ?>
">
					<td><?php 
                echo $sidebar;
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar;
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="Remove this sidebar">remove</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="3">No Sidebars defined</td>
					</tr>
					<?php 
        }
        ?>
			</table>
			<br /><br />
			<div class="donate">
				<h5>Donate</h5>
				<p>
					Support the further development of this plugin.
				</p>
				<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="hosted_button_id" value="9271055">
				<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
				<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
				</form>

			</div>
		</div>
		<?php 
    }
    function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					//alert('AJAX REMOVE');
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("Sidebar Name:","");
				
				//alert(sidebar_name);
				if (sidebar_name!=null)
				{
				 add_sidebar(sidebar_name);
				}
			}
		</script>
		<div class="wrap">
			<h2>Sidebar Generator</h2>
			<p>
				The sidebar name is for your use only. It will not be visible to any of your visitors. 
				<br />A CSS class is assigned to each of your sidebar, use this styling to customize the sidebars.
			</p>
			<p>
				Go to "Appearance > Widgets" to manage the widgets inside each of the sidebars created.
				<br />In the write-panel of "Pages/Posts" you'll be able to assign the sidebars created accordingly.
			</p>
			<br />
			<div class="add_sidebar">
				<a href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar">+ Add Sidebar</a>
			</div>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th>Name</th>
					<th>CSS class</th>
					<th>Remove</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
				<tr class="<?php 
                echo $alt;
                ?>
">
					<td><?php 
                echo $sidebar;
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar;
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="Remove this sidebar">remove</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="3">No Sidebars defined</td>
					</tr>
					<?php 
        }
        ?>
			</table>

		<?php 
    }
    function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,num){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					//alert('AJAX REMOVE');
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("Sidebar Name:","");
				add_sidebar(sidebar_name);
			}
		</script>
		<div class="wrap">
			<h2><?php 
        _e('Custom Sidebars', 'color-theme-framework');
        ?>
</h2>
			<br />
			<div class="add_sidebar">
				<a href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar">+ Add Sidebar</a>
			</div>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th>Name</th>
					<th>CSS class</th>
					<th>Remove</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>
				<tr class="<?php 
                echo $alt;
                ?>
">
					<td><?php 
                echo $sidebar;
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar;
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="Remove this sidebar">remove</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr>
						<td colspan="3"><?php 
            _e('No Sidebars defined', 'color-theme-framework');
            ?>
</td>
					</tr>
					<?php 
        }
        ?>
			</table>
			<br /><br />
		</div>
		<?php 
    }
function sidebars()
{
    ?>
	<script>
		function remove_sidebar_link(name,num){
			answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
			if(answer){
				//alert('AJAX REMOVE');
				remove_sidebar(name,num);
				jQuery('#messages').html('<div class="success-message"><p>Sidebar successfully removed.</p></div>').show('normal');
			}else{
				return false;
			}
		}
		function add_sidebar_link(){
			var sidebar_name = jQuery('#add-sidebar').val();
			if(sidebar_name.length > 0)
			{
				add_sidebar(sidebar_name);
				jQuery('#add-sidebar').val('');
				jQuery('#messages').html('<div class="success-message"><p>Sidebar successfully created.</p></div>').show('normal');
			}
		}
	</script>
	
	<div id="header">
        <div id="logo-container">
			<h1><img src="<?php 
    echo get_template_directory_uri();
    ?>
/library/admin/images/main_logo.png" alt="Alcatron" /></h1>		
        </div>	
        <div id="admin-panel">
            <p>Administration Panel</p>
        </div>       
        <div class="clear"></div>
	</div>
	<div class="wrap alc_wrap" style="padding:10px">
	<div id="messages" style="display:none"></div>
		<div id="main_wrap">
			<div class="alc_opts">	
				<h3 class="tg-title" style="padding-top:0px; color:#333">Sidebar Generator</h3>
				<p>
					The sidebar name is for your use only. It will not be visible to any of your visitors. 
					A CSS class is assigned to each of your sidebar, use this styling to customize the sidebars.
				</p>
				<br />
				<div class="add_sidebar">
					<form method="POST" action="" id="sidebar-form" onsubmit="add_sidebar_link(); return false;">
						<label for="add-sidebar" style="float:none">Create a new sidebar</label>
						<input type="text" id="add-sidebar" style="height:30px"  />
						<a href="javascript:void(0);" class="alc-button medium" onclick="return add_sidebar_link()" title="Add a sidebar">Create</a>
					</form>
				</div>
				<br />
				<table class="list-table" id="sbg_table" >
					<tr>
						<th>Name</th>
						<th>CSS class</th>
						<th style="width:80px; text-align:center">Remove</th>
					</tr>
					<?php 
    $sidebars = sidebar_generator::get_sidebars();
    //$sidebars = array('bob','john','mike','asdf');
    if (is_array($sidebars) && !empty($sidebars)) {
        $cnt = 0;
        foreach ($sidebars as $sidebar) {
            $alt = $cnt % 2 == 0 ? 'alternate' : '';
            ?>
					<tr class="<?php 
            echo $alt;
            ?>
">
						<td><?php 
            echo $sidebar;
            ?>
</td>
						<td><?php 
            echo sidebar_generator::name_to_class($sidebar);
            ?>
</td>
						<td style="text-align:center"><a href="javascript:void(0);" class="alc-button red-back medium" onclick="return remove_sidebar_link('<?php 
            echo $sidebar;
            ?>
',<?php 
            echo $cnt + 1;
            ?>
);" title="Delete">Delete</a></td>
					</tr>
					<?php 
            $cnt++;
        }
    } else {
        ?>
						<tr>
							<td colspan="3">No Sidebars defined</td>
						</tr>
						<?php 
    }
    ?>
				</table>
				<br /><br />
				
			</div>
		</div>
	</div>
	<?php 
}
Ejemplo n.º 11
0
    public static function admin_page()
    {
        ?>
		<script>
			function remove_sidebar_link(name,id){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					remove_sidebar(name,id);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt("<?php 
        _e('Sidebar Name:', 'ThemeStockyard');
        ?>
","");
				if(jQuery.trim(sidebar_name)) {
                    add_sidebar(sidebar_name);
				} else {
                    return false
				}
			}
		</script>
		<div class="wrap">
			<h2><?php 
        _e('Sidebar Manager', 'ThemeStockyard');
        ?>
</h2>
			<div id="ts-multiple-sidebars-response" style="display:none"></div>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th><?php 
        _e('Sidebar Name', 'ThemeStockyard');
        ?>
</th>
					<th><?php 
        _e('CSS class', 'ThemeStockyard');
        ?>
</th>
					<th><?php 
        _e('Remove', 'ThemeStockyard');
        ?>
</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                $id = sidebar_generator::name_to_class($sidebar);
                ?>
				<tr class="<?php 
                echo esc_attr($alt);
                ?>
" id="sbg-row-<?php 
                echo esc_attr($id);
                ?>
">
					<td><?php 
                echo esc_attr($sidebar);
                ?>
</td>
					<td><?php 
                echo esc_attr($id);
                ?>
</td>
					<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo esc_js($sidebar);
                ?>
','<?php 
                echo esc_js($id);
                ?>
');" title="Remove this sidebar"><?php 
                _e('remove', 'ThemeStockyard');
                ?>
</a></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>
					<tr id="sbg-no-sidebars-yo">
						<td colspan="3"><?php 
            _e('No Sidebars defined', 'ThemeStockyard');
            ?>
</td>
					</tr>
					<?php 
        }
        ?>
			</table><br /><br />
            <div class="add_sidebar">
				<a href="javascript:void(0);" onclick="return add_sidebar_link()" title="Add a sidebar" class="button-primary"><?php 
        _e('+ Add New Sidebar', 'ThemeStockyard');
        ?>
</a>

			</div>
			
		</div>
		<?php 
    }
Ejemplo n.º 12
0
global $smof_data, $ts_page_id, $post, $ts_grab_home_sidebar, $ts_show_sidebar, $ts_sidebar_position, $ts_sidebar_instance;
if (!isset($ts_show_sidebar) || ts_is_woo_shop()) {
    if (is_single()) {
        $ts_show_sidebar = ts_postmeta_vs_default($ts_page_id, '_p_sidebar', 'yes');
    } else {
        $ts_show_sidebar = ts_postmeta_vs_default($ts_page_id, '_page_sidebar', 'yes');
    }
}
if ($ts_show_sidebar == 'yes') {
    $ts_sbs = $ts_sidebar_selection_id = '';
    $ts_sidebar_selection = get_post_meta($ts_page_id, '_sbg_selected_sidebar_replacement', true);
    $ts_sidebar_selection = is_array($ts_sidebar_selection) ? $ts_sidebar_selection[0] : $ts_sidebar_selection;
    if ($ts_sidebar_selection && class_exists('sidebar_generator')) {
        $ts_sidebar_selection_options = sidebar_generator::get_sidebars();
        $ts_sidebar_selection_name = $ts_sbs = str_replace(array("\n", "\r", "\t", ' '), '', $ts_sidebar_selection);
        $ts_sidebar_selection_id = sidebar_generator::name_to_class($ts_sidebar_selection_name);
        if (!isset($ts_sidebar_selection_options[$ts_sidebar_selection_id])) {
            $ts_sidebar_selection = 0;
        }
    }
    ?>

		<div id="sidebar" class="<?php 
    echo esc_attr($ts_sbs);
    ?>
 sidebar <?php 
    echo esc_attr('sidebar-' . $ts_sidebar_position);
    ?>
">
            <?php 
    if ($ts_sidebar_selection && class_exists('sidebar_generator') && is_active_sidebar('ts-custom-sidebar-' . strtolower($ts_sidebar_selection_id))) {
    public static function admin_page()
    {
        ?>

		<script>
			function add_sidebar_link_listener(){
				
				var btns = jQuery('.sidebar-remove-btn');
				
				jQuery('#sidebar-name').attr('value','');
				
				if(btns.length > 0){
					jQuery('.sidebar-tip').css('display','none');
				}else{
					jQuery('.sidebar-tip').css('display','block');
				}
				
				jQuery(btns).each(function(index, element) {
                    if(jQuery(this).attr('data-click')){
					}else{
						jQuery(this).attr('data-click','yes');
						add_click_event(jQuery(this));
					}
                });
				
			}
			
			function add_click_event(element){
				jQuery(element).click(function(e) {
					var name = jQuery(this).parent().parent().children('td').get(1).textContent;
					var items = jQuery('#sbg_table tr');
					var num	 = 0;
					
					for(var i=0; i<items.length; i++){
						if(jQuery(items[i]).children('td').length > 0){
							if(jQuery(items[i]).children('td').get(1).textContent == name){
								num = i;
								break;
							}
						}
					}
					
					remove_sidebar_link(name,num);
				});
			}
			
			function remove_sidebar_link(name,num){
				answer = confirm("Are you sure you want to remove " + name + "?\nThis will remove any widgets you have assigned to this sidebar.");
				if(answer){
					//alert('AJAX REMOVE');
					remove_sidebar(name,num);
				}else{
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = jQuery('#sidebar-name').attr('value');
				if(sidebar_name == '' || sidebar_name.length == 0) {
					return false;
				}
				//var sidebar_name = prompt("Sidebar Name:","");
				//alert(sidebar_name);
				add_sidebar(sidebar_name);
			}
			jQuery(document).ready(function(e) {
                add_sidebar_link_listener();
            });
		</script>
		<div class="wrap">
			<h2>Sidebar Generator</h2>
			<br />
			<table class="widefat page" id="sbg_table" style="width:600px;">
				<tr>
					<th>Name</th>
					<th>CSS class</th>
					<th>Remove</th>
				</tr>
				<?php 
        $sidebars = sidebar_generator::get_sidebars();
        //$sidebars = array('bob','john','mike','asdf');
        if (is_array($sidebars) && !empty($sidebars)) {
            $cnt = 0;
            foreach ($sidebars as $sidebar) {
                $alt = $cnt % 2 == 0 ? 'alternate' : '';
                ?>

				<tr class="<?php 
                echo $alt;
                ?>
">
					<td><?php 
                echo $sidebar;
                ?>
</td>
					<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
					<td><input type="button" class="button-primary sidebar-remove-btn" value="remove" /></td>
				</tr>
				<?php 
                $cnt++;
            }
        } else {
            ?>

					<!--<tr>
						<td colspan="3">No Sidebars defined</td>
					</tr>-->
					<?php 
        }
        ?>

			</table>
            <p class="sidebar-tip">No Sidebars defined!</p>
            <br /><br />
            <div class="add_sidebar">
            <h4>Add Sidebar: </h4>
            	<input id="sidebar-name" type="text" class="regular-text" placeholder="Input sidebar name" />
            </div>
			<p class="submit">
            	<input type="button" onclick="add_sidebar_link();" class="button-primary" value="Add New Sidebar" />
            </p>
		</div>
		<?php 
    }
Ejemplo n.º 14
0
    public static function admin_page()
    {
        ?>
		<script>
		function remove_sidebar_link(name,num){
			answer = confirm( "<?php 
        esc_html_e('Are you sure you want to remove', 'Avada');
        ?>
 " + name + "?\n<?php 
        esc_html_e('This will remove any widgets you have assigned to this widget section.', 'Avada');
        ?>
" );
				if ( answer ) {
					//alert('AJAX REMOVE');
					remove_sidebar( name, num );
				} else {
					return false;
				}
			}
			function add_sidebar_link(){
				var sidebar_name = prompt( "<?php 
        esc_html_e('Widget Section Name:', 'Avada');
        ?>
","" );
				//alert(sidebar_name);
				if ( sidebar_name === null || sidebar_name == '' ) {
					return;
				}

				add_sidebar( sidebar_name );
			}
		</script>
		<div class="postbox" style="max-width:1719px;">
			<h2 class="hndle ui-sortable-handle" style="padding: 15px 12px; margin: 0;">
				<span><?php 
        esc_html_e('Widget Sections', 'Avada');
        ?>
</span>
			</h2>
			<div class="inside" style="margin-bottom: 0;">
				<table class="widefat page" id="sbg_table">
					<tr>
						<th><?php 
        esc_html_e('Widget Section Name', 'Avada');
        ?>
</th>
						<th><?php 
        esc_html_e('CSS Class', 'Avada');
        ?>
</th>
						<th><?php 
        esc_html_e('Remove', 'Avada');
        ?>
</th>
					</tr>
					<?php 
        $sidebars = sidebar_generator::get_sidebars();
        ?>
					<?php 
        if (is_array($sidebars) && !empty($sidebars)) {
            ?>
						<?php 
            $cnt = 0;
            ?>
						<?php 
            foreach ($sidebars as $sidebar) {
                ?>
							<?php 
                $alt = 0 == $cnt % 2 ? 'alternate' : '';
                ?>
							<tr class="<?php 
                echo $alt;
                ?>
">
								<td><?php 
                echo $sidebar;
                ?>
</td>
								<td><?php 
                echo sidebar_generator::name_to_class($sidebar);
                ?>
</td>
								<td><a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php 
                echo $sidebar;
                ?>
',<?php 
                echo $cnt + 1;
                ?>
);" title="<?php 
                esc_html_e('Remove this Widget Section', 'Avada');
                ?>
"><?php 
                esc_attr_e('remove', 'Avada');
                ?>
</a></td>
							</tr>
							<?php 
                $cnt++;
                ?>
						<?php 
            }
            ?>
					<?php 
        } else {
            ?>
						<tr id="no-widget-sections">
							<td colspan="3"><?php 
            esc_html_e('No Widget Sections defined.', 'Avada');
            ?>
</td>
						</tr>
					<?php 
        }
        ?>
				</table>
				<p class="add_sidebar"><a href="javascript:void(0);" onclick="return add_sidebar_link()" title="<?php 
        _e('Add New Widget Section', 'Avada');
        ?>
" class="button button-primary"><?php 
        _e('Add New Widget Section', 'Avada');
        ?>
</a></p>
			</div>
		</div>
		<?php 
    }
 function remove_sidebar()
 {
     $sidebars = sidebar_generator::get_sidebars();
     $name = str_replace(array("\n", "\r", "\t"), '', $_POST['sidebar_name']);
     $id = sidebar_generator::name_to_class($name);
     if (!isset($sidebars[$id])) {
         die("alert('Sidebar does not exist.')");
     }
     $row_number = $_POST['row_number'];
     unset($sidebars[$id]);
     sidebar_generator::update_sidebars($sidebars);
     $js = "\n\t\t\tvar tbl = document.getElementById('sbg_table');\n\t\t\ttbl.deleteRow({$row_number});\n\n\t\t";
     die($js);
 }