Ответы в темах

Просмотр 4 ответов — с 1 по 4 (всего 4)
  • Всё, догнал, надо права проставить для регистрирующихся.
    Спасибо.

    Нет, я видимо не ясно изъяснился. Надо чтобы пользователь зарегистрировался, потом смог нажатием кнопки, войти в редактор создания страницы. Этого меню у него не должно быть.
    С правами автора, наверное.

    • Ответ изменён 4 года, 4 месяца назад пользователем babylonix.

    Здесь можно глянуть работу: http://rubaz.ru/
    Только по одному 🙂 сохраняет в один файл, скрипт для администратора.
    Здесь загрузить сам плагин: https://runza.ru/index.php?topic=2.msg2#msg2

    • Ответ изменён 4 года, 7 месяцев назад пользователем babylonix.

    Написал плагин… Уж как вышло. 🙂
    Вот файл подключения к WP, всё работает, но гляньте, что я безграмотно сделал?

    
    <?php
    /*
    Plugin Name: Sites coloring
    Plugin URI: https://runza.ru/index.php?topic=2.0
    Description: Color any WP site, you don't need to know CSS. Very simple: click with the left mouse button - paint, right click - cancel.
    Version: 1.0
    Author: Alexander Zhernovkov
    Author URI: http://runza.ru
    License: GPL2
    */
    
    if(!defined('WP_CONTENT_URL'))
    	define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
    if(!defined('WP_CONTENT_DIR'))
    	define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
    if(!defined('WP_PLUGIN_URL'))
    	define('WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins');
    if(!defined('WP_PLUGIN_DIR'))
    	define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
    
    	
    class STbox {
    
        function cssStyles() {
          $stPath = WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/css'.'/';
          echo '<link rel="stylesheet" type="text/css" media="screen" href="' . $stPath . 'coloring.css" />'."\n";
        }
    
        function headerCssbox() {
    	$bodyDiv = '
    	<style type="text/css">body {opacity: 0;}</style>
    	<div class="comm">
    	<div id="modal_form">
    	CSS reset?<br><br>
    		<button class="CSSok">OK</button>
    		<button class="no">NO</button>
    	</div>
    	<div id="overlay"></div>
    	<div id="modal_formm">
    	All reset?<br><br>
    		<button class="Allok">OK</button>
    		<button class="no">NO</button>
    	</div>
    	<div id="overlayy"></div>
    	<div class="in">
    		<div class="probs">
    			<button class="butt">Sample:</button>
              	<input class="prob" value="Body" readonly="readonly">
              	<input class="prob" value="Link" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
              	<input class="prob" value="Sample" readonly="readonly">
    		</div>
    		<div class="bgrs">
    			<button class="butt">Background:</button>
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
              	<input class="jscolor {hash:true,position:\'left\'} bgr">
    
    		</div>
    		<div class="cols">
    			<button class="butt">Color:</button>
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
              	<input class="jscolor {hash:true,position:\'left\'} col">
    		</div>
    	</div>
    	<div class="knop">
    		<button class="but" id="Allreset">All reset</button>
    		<button class="but" id="CSSreset">CSS reset</button>
    		<button class="but" id="but">noLink</button>
    	</div>
    </div>
    <div id="tooltip"></div>
    <div id="cssbox">
    ';
    	
    		echo $bodyDiv;
    	}
        function headerCssboxEnd() {
    		$bodyDivEnd = '	</div> <!-- #cssbox -->'."\n";
    		echo $bodyDivEnd;
    	}
    }
    
    function RelatedPosts( $atts ) {
    	extract(shortcode_atts(array(
    	    'limit' => '5',
    	), $atts));
    
    	global $wpdb, $post, $table_prefix;
    
    	if ($post->ID) {
    		$retval = '<ul>';
    
    		$tags = wp_get_post_tags($post->ID);
    		$tagsarray = array();
    		foreach ($tags as $tag) {
    			$tagsarray[] = $tag->term_id;
    		}
    		$tagslist = implode(',', $tagsarray);
    
    		$q = "SELECT p.*, count(tr.object_id) as count
    			FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p WHERE tt.taxonomy ='post_tag' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id  = p.ID AND tt.term_id IN ($tagslist) AND p.ID != $post->ID
    				AND p.post_status = 'publish'
    				AND p.post_date_gmt < NOW()
     			GROUP BY tr.object_id
    			ORDER BY count DESC, p.post_date_gmt DESC
    			LIMIT $limit;";
    
    		$related = $wpdb->get_results($q);
     		if ( $related ) {
    			foreach($related as $r) {
    				$retval .= '<li><a title="'.wptexturize($r->post_title).'" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></li>';
    			}
    		} else {
    			$retval .= '
    	<li>Нет связанных материалов.</li>';
    		}
    		$retval .= '</ul>';
    		return $retval;
    	}
    	return;
    }
    
    function jScript() {
    	wp_enqueue_script( 'jquery');
    	wp_enqueue_script( 'jscolor', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)) . '/js/jscolor.js', true );
    	wp_enqueue_script( 'js_style', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)) . '/js/js_style.js', array('jquery'), '', true );
    }
    	add_action( 'wp_enqueue_scripts', 'jScript' );
    
    if (class_exists("STbox")) {
    	$dl_plugin = new STbox();
    }
    
    if (isset($dl_plugin)) {
    
    	add_action('wp_head', array(&$dl_plugin, 'cssStyles'));
    	add_action('wp_body_open', array(&$dl_plugin, 'headerCssbox'));
    	add_action('wp_footer', array(&$dl_plugin, 'headerCssboxEnd'));
    
    }
    
    add_shortcode('link', 'URL');
    add_shortcode('DownloadButton', 'DownloadButton');
    add_shortcode('RelatedPosts', 'RelatedPosts');
    
    ?>
    
Просмотр 4 ответов — с 1 по 4 (всего 4)