New Paste

 

Recent Pastes

Administrate




PageLines PasteBin.

PasteID: 9bf
Pasted by Anonymous, 2012-08-13 15:58:08 GMT
Expires Never
Paste size 2.85 Kb
Toggle Expand   Wrap   Raw
Copy Contents   Copy URL
 
  1. <?php
  2. /*
  3. Plugin Name: Rotate the logos!
  4. Plugin URI: http://www.pagelines.com
  5. Author: PageLines
  6. Author URI: http://www.pagelines.com
  7. Description: Rotates your logo!
  8. PageLines: true
  9. Version: 0.1
  10. */
  11.  
  12. class PageLinesRotate {
  13.  
  14. 	/**
  15. 	 * Construct, always run when class is initiated
  16. 	 *
  17. 	 */
  18. 	function __construct() {
  19.  
  20.  
  21. 		if ( is_admin() )
  22. 			$this->admin_setup();
  23. 		else
  24. 			add_action( 'init', array( $this, 'rotate_filter' ) );
  25. 	}	
  26.  
  27. 	function rotate_filter() {
  28.  
  29. 		$max = ploption( 'pagelines_rotates_max' );
  30.  
  31. 		if ( ! $max )
  32. 			$max = 2;
  33.  
  34. 		$this->rand = rand( 1, $max );
  35.  
  36. 		add_filter( 'ploption_pagelines_custom_logo', array( $this, 'do_rotate_image' ), 10, 2 );
  37. 		add_filter( 'ploption_pagelines_custom_logo_url', array( $this, 'do_rotate_image_url' ), 10, 2 );	
  38. 	}
  39.  
  40. 	function do_rotate_image_url( $key, $o ) {
  41.  
  42. 		$url = ploption( "pagelines_rotates_url_{$this->rand}" );
  43.  
  44. 		if ( $url ) {
  45. 			return $url;			
  46. 		}
  47. 		return get_ploption( $key );
  48. 	}
  49.  
  50. 	function do_rotate_image( $key, $o ) {
  51.  
  52. 		$img = ploption( "pagelines_rotates_img_{$this->rand}" );
  53.  
  54. 		if ( $img ) {
  55. 			return $img;			
  56. 		}
  57. 		return get_ploption( $key );
  58. 	}
  59.  
  60.  
  61. 	function admin_setup() {
  62.  
  63. 		add_action( 'admin_init', array( &$this, 'admin_page' ) );
  64.  
  65. 	}
  66.  
  67.  
  68. 	function admin_page() {
  69.  
  70. 		pl_add_options_page( array( 
  71. 			'name'	=> 'rotator',
  72. 			'raw'	=> $this->rotate_intro(),
  73. 		 	'title'	=> 'Rotator Instructions.'	
  74. 		) );
  75. 		pl_global_option( array( 'menu' => 'rotator', 'options' => $this->rotate_options(), 'location' => 'bottom' ) );	
  76. 	}
  77.  
  78. 	function rotate_options() {
  79.  
  80. 		$rotates_max = ploption( 'pagelines_rotates_max' );
  81.  
  82. 		if ( ! $rotates_max )
  83. 			$rotates_max = 2;
  84.  
  85. 		$options = array(
  86.  
  87. 			'pagelines_rotates_opts' => array(
  88.  
  89. 			'type'	=>	'multi_option',
  90. 			'title'	=>	'Rotate options...',
  91. 			'selectvalues'	=>	array(
  92.  
  93. 				'pagelines_rotates_max'	=>	array(
  94. 				'default'		=> 2,
  95. 				'inputlabel'	=> 'How many?',
  96. 				'type'			=> 'count_select',
  97. 				'count_start'	=> 2, 
  98. 				'count_number'	=> 100,
  99. 				)
  100. 			),
  101.  
  102.  
  103. 		) );
  104.  
  105.  
  106.  
  107. 		for($i = 1; $i <= $rotates_max; $i++) {
  108.  
  109. 			$options['pagelines_rotates_opts']['selectvalues']["pagelines_rotates_img_{$i}"] = array(
  110.  
  111. 				'type'	=>	'image_upload',
  112. 				'title'	=>	sprintf( 'Image number %s', $i )
  113. 			);
  114. 			$options['pagelines_rotates_opts']['selectvalues']["pagelines_rotates_url_{$i}"] = array(
  115. 				'type'	=>	'text',
  116. 				'inputlabel'	=>	sprintf( 'Url for Image number %s', $i )		
  117. 			);
  118.  
  119.  
  120. 		}		
  121. 		return $options;
  122. 	}
  123.  
  124.  
  125. 	function rotate_intro() {
  126.  
  127. 		return '<p>Select how many random images below, then simply upload them and add a URL. Simples.</p>';	
  128. 	}
  129.  
  130.  
  131.  
  132. } // class end
  133.  
  134.  
  135. // this starts the plugin code.
  136. new PageLinesRotate;
 
 
 

 
 
 
 
 
Written by Xan Manning, 2010.
YOU NEED FLASH!