added hangar plugin with support for svg, category and tags in pages
This commit is contained in:
parent
873809c3dc
commit
36ebf79294
|
@ -0,0 +1,5 @@
|
|||
/* hangar wp plugin styles
|
||||
*
|
||||
* css styles
|
||||
*
|
||||
*/
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* @link https://hangar.org
|
||||
* @since 1.0.0
|
||||
* @package hangar_WP_Plugin
|
||||
*
|
||||
* Plugin Name: Hangar wordpress plugin
|
||||
* Plugin URI: https://git.hangar.org
|
||||
* Description: Different needs for the Hangar Wordpress theme needs. Tag pages, show tagged content in page view, old posts. Adds support for: SVG.
|
||||
* Date: 2022 07 10
|
||||
* Version: 1.0.0
|
||||
* Author: jorge - vitrubio.net
|
||||
* Author URI: https://vitrubio.net/
|
||||
* License: GPL 3.0
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* Text Domain: hangar-plugin
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
/*
|
||||
if ever read this never forget to check
|
||||
howto write a pluggin by Wordpress.org
|
||||
https://codex.wordpress.org/Writing_a_Plugin
|
||||
and the best practices
|
||||
https://developer.wordpress.org/plugins/plugin-basics/best-practices/
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
//defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Currently plugin version.
|
||||
* Start at version 1.0.0 and use SemVer - https://semver.org
|
||||
* Rename this for your plugin and update it as you release new versions.
|
||||
*/
|
||||
define( 'HANGAR_WPPLUGIN_VERSION', '1.0.0' );
|
||||
|
||||
/* *
|
||||
* define Plugin path
|
||||
* https://developer.wordpress.org/reference/functions/plugin_dir_path/#comment-1113
|
||||
* * * * * * * * * * * * * * * * * * */
|
||||
define( 'HANGAR_WPPLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
||||
|
||||
include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-init-textdomain.php');
|
||||
|
||||
include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-enable-svg.php');
|
||||
|
||||
if ( is_admin() ) {
|
||||
include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-stylesheet-admin.php');
|
||||
} else {
|
||||
include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-stylesheet-public.php');
|
||||
}
|
||||
|
||||
include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-custom-post-type-resources.php');
|
||||
|
||||
include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-tags-and-pages.php');
|
||||
|
||||
//include( HANGAR_WPPLUGIN_PATH . 'includes/hangar-tags-category-shortcode.php');
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Add mimetypes support: svg
|
||||
*
|
||||
* @link https://hangar.org
|
||||
* @since 1.0.0
|
||||
* @package hangar-wp-plugin
|
||||
* @subpackage hangar-wp-plugin/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add mimetypes support: svg
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package hangar-wp-plugin
|
||||
* @subpackage hangar-wp-plugin/includes
|
||||
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
|
||||
*/
|
||||
|
||||
function hangar_enable_mime_types( $mimes ) {
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}
|
||||
add_filter('upload_mimes', 'hangar_enable_mime_types');
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Load translation, if it exists
|
||||
*
|
||||
* @link https://hangar.org
|
||||
* @since 1.0.0
|
||||
* @package hangar-wp-plugin
|
||||
* @subpackage hangar-wp-plugin/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load translation, if it exists
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package hangar-wp-plugin
|
||||
* @subpackage hangar-wp-plugin/includes
|
||||
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
|
||||
*/
|
||||
|
||||
function hangar_init_textdomain() {
|
||||
load_plugin_textdomain( 'hangar-wpplugin', null, plugin_dir_path( __FILE__ ).'/assets/languages/' );
|
||||
}
|
||||
add_action('plugins_loaded', 'hangar_init_textdomain');
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Registers admin stylesheet for a custom plugin.
|
||||
*
|
||||
* @link https://hangar.org
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package hangar-wp-plugin
|
||||
* @subpackage hangar-wp-plugin/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers admin stylesheet for a custom plugin.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package hangar-wp-plugin
|
||||
* @subpackage hangar-wp-plugin/includes
|
||||
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
|
||||
*/
|
||||
|
||||
function hangar_admin_styles() {
|
||||
add_editor_style( 'assets/css/hangar-wpplugin-admin-styles.css' );
|
||||
}
|
||||
add_action( 'admin_init', 'hangar_admin_styles' );
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Registers public stylesheet for a custom plugin.
|
||||
*
|
||||
* @link https://hangar.org
|
||||
* @since 1.1.0
|
||||
*
|
||||
* @package hangar_wp-plugin
|
||||
* @subpackage hangar_wp-plugin/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers public stylesheet for a custom plugin.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @package hangar_wp-plugin
|
||||
* @subpackage hangar_wp-plugin/includes
|
||||
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
|
||||
*/
|
||||
|
||||
function hangar_public_styles() {
|
||||
add_editor_style( 'assets/css/hangar-wpplugin-styles.css' );
|
||||
}
|
||||
add_action( 'admin_init', 'hangar_public_styles' );
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/******************************************************************************
|
||||
New Plugin Name: Hangar tag pages and show tagged content in pages
|
||||
New Plugin URI: https://git.hangar.org
|
||||
New Description: Add tags to Pages, just as you would do with Posts
|
||||
License: GPLv2 or later
|
||||
|
||||
*******************************************************************************
|
||||
Adding tags to pages based on the work of:
|
||||
Original Plugin Name: Tag Pages
|
||||
Original Plugin URI: https://burobjorn.nl
|
||||
Original WP Plugin URI: https://wordpress.org/plugins/tag-pages/
|
||||
Original Version: 1.0.2
|
||||
Original Author: Bjorn Wijers <burobjorn at burobjorn dot nl>
|
||||
Original Author URI: https://burobjorn.nl
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright 2012
|
||||
Tag Pages is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Tag Pages is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Add the 'post_tag' taxonomy, which is the name of the existing taxonomy
|
||||
* used for tags to the Post type page. Normally in WordPress Pages cannot
|
||||
* be tagged, but this let's WordPress treat Pages just like Posts
|
||||
* and enables the tags metabox so you can add tags to a Page.
|
||||
* NB: This uses the register_taxonomy_for_object_type() function which is only
|
||||
* in WordPress 3 and higher!
|
||||
*/
|
||||
|
||||
// add tag and category support to pages
|
||||
if( ! function_exists ('hangar_category_tags_support_all') ){
|
||||
function hangar_category_tags_support_all()
|
||||
{
|
||||
register_taxonomy_for_object_type('post_tag', 'page');
|
||||
register_taxonomy_for_object_type('category', 'page');
|
||||
}
|
||||
add_action('init', 'hangar_category_tags_support_all');
|
||||
}
|
||||
|
||||
// ensure all pages are included in tag and category queries
|
||||
if( ! function_exists ('hangar_category_tags_support_query') ){
|
||||
function hangar_category_tags_support_query($wp_query) {
|
||||
if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
|
||||
if ($wp_query->get('category')) $wp_query->set('post_type', 'any');
|
||||
}
|
||||
add_action('pre_get_posts', 'hangar_category_tags_support_query');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all post_types on the tags archive page. This forces WordPress to
|
||||
* show tagged Pages together with tagged Posts. Thanks to Page Tagger by
|
||||
* Ramesh Nair: http://wordpress.org/extend/plugins/page-tagger/
|
||||
*/
|
||||
if( ! function_exists('hangar_tagpages_display_tagged_pages_archive') ){
|
||||
function hangar_tagpages_display_tagged_pages_archive(&$query)
|
||||
{
|
||||
if ( !is_admin() && $query->is_archive && $query->is_tag ) {
|
||||
$q = &$query->query_vars;
|
||||
$q['post_type'] = 'any';
|
||||
}
|
||||
}
|
||||
add_action('pre_get_posts', 'hangar_tagpages_display_tagged_pages_archive');
|
||||
}
|
||||
|
||||
|
||||
// show category using shortcode
|
||||
// https://stackoverflow.com/a/13996873
|
||||
if( ! function_exists('hangar_show_categoriced') ){
|
||||
function hangar_show_categoriced()
|
||||
{
|
||||
add_shortcode('hangar-catlist', function($atts, $content) {
|
||||
$atts += array('category' => 1);
|
||||
$posts = get_posts("category={$atts['category']}");
|
||||
|
||||
foreach ($posts as $post) {
|
||||
echo $post->post_name . '<br />';
|
||||
}
|
||||
});
|
||||
echo do_shortcode('[hangar-catlist category=5]');
|
||||
}
|
||||
}
|
||||
if( ! function_exists('hangar_show_tagged') ){
|
||||
function hangar_show_tagged()
|
||||
{
|
||||
add_shortcode('hangar-taglist', function($atts, $content) {
|
||||
$atts += array('tag' => 1);
|
||||
$posts = get_posts("tag={$atts['tag']}");
|
||||
|
||||
foreach ($posts as $post) {
|
||||
echo $post->post_name . '<br />';
|
||||
}
|
||||
});
|
||||
echo do_shortcode('[hangar-taglist tag=5]');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: category post shortcode
|
||||
Plugin URI: http://ibnuyahya.com/wordpress-plugins/category-post-shortcode/
|
||||
wp Plugin URI: https://wordpress.org/plugins/category-post-shortcode/
|
||||
Description: To display post by category in your page/post
|
||||
Author: ibnuyahya
|
||||
Author URI: http://ibnuyahya.com/
|
||||
Version: 2.4
|
||||
|
||||
Contributors
|
||||
Ben McFadden - https://github.com/mcfadden
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* How to use
|
||||
* =============================================================================
|
||||
* just put this shortcode in your post or pages
|
||||
*
|
||||
* [cat totalposts="3" category="1,3" thumbnail="true" excerpt="true" ]
|
||||
*
|
||||
* totalposts - your total number of post to display. default is -1
|
||||
* category - category id. use comma , for multiple id
|
||||
* thumbnail - set true if you want to display thumbnail. default is false
|
||||
* thumbnail_height - image size for the thumbnail. default is 130
|
||||
* thumbnail_width - image size for the thumbnail. default is 130
|
||||
* excerpt - set true if you want to display excertp. default is true
|
||||
* date - set true if you want to display post date. default is false
|
||||
* orderby - your post will order by . default post_date . check http://codex.wordpress.org/Template_Tags/get_posts for detail
|
||||
* order - asc | desc
|
||||
*
|
||||
* thumbnail
|
||||
* =============================================================================
|
||||
* create custom field key as thumbnail-url and put your thumbnail url in the value area
|
||||
*
|
||||
* style at your own
|
||||
* =============================================================================
|
||||
* you need to style your category-post-shortcode plugin in your style.css example
|
||||
|
||||
.cat-post{
|
||||
width:100%;
|
||||
}
|
||||
.cat-post-list{
|
||||
display: block;
|
||||
margin-bottom: 20px;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
.cat-post-images{
|
||||
float:left;
|
||||
width:140px;
|
||||
display:block;
|
||||
}
|
||||
|
||||
.cat-content{
|
||||
width:350px;
|
||||
float:right;
|
||||
}
|
||||
.cat-post-title{
|
||||
display: block;
|
||||
width:100%;
|
||||
}
|
||||
.cat-post-date
|
||||
display: block;
|
||||
width:100%;
|
||||
}
|
||||
.cat-clear{
|
||||
clear:both;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
function cat_func($atts) {
|
||||
extract(shortcode_atts(array(
|
||||
'class_name' => 'cat-post',
|
||||
'totalposts' => '-1',
|
||||
'category' => '',
|
||||
'thumbnail' => 'false',
|
||||
'thumbnail_height' => '130',
|
||||
'thumbnail_width' => '130',
|
||||
'date' => 'false',
|
||||
'excerpt' => 'true',
|
||||
'orderby' => 'post_date',
|
||||
'order' => 'desc'
|
||||
), $atts));
|
||||
|
||||
$output = '<div class="'.$class_name.'">';
|
||||
global $post;
|
||||
$tmp_post = $post;
|
||||
$myposts = get_posts("numberposts=$totalposts&category=$category&orderby=$orderby&order=$order");
|
||||
|
||||
foreach($myposts as $post) {
|
||||
setup_postdata($post);
|
||||
$output .= '<div class="cat-post-list">';
|
||||
if($thumbnail == 'true') {
|
||||
$thumb_image = get_post_meta($post->ID, 'thumbnail-url',true);
|
||||
if(empty($thumb_image)){
|
||||
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
|
||||
$thumb_image = $matches [1] [0];
|
||||
}
|
||||
if(empty($thumb_image)){
|
||||
$thumb_image ='';
|
||||
}
|
||||
|
||||
$output .= '<div class="cat-post-images"><img height="'.$thumbnail_height.'" width="'.$thumbnail_width.'" src="'.$thumb_image.'" /></div>';
|
||||
}
|
||||
$output .= '<div class="cat-content"><span class="cat-post-title"><a href="'.get_permalink().'">'.get_the_title().'</a></span>';
|
||||
if ($date == 'true') {
|
||||
$output .= '<span class="cat-post-date">'.get_the_date().'</span>';
|
||||
}
|
||||
if ($excerpt == 'true') {
|
||||
$output .= '<span class="cat-post-excerpt">'.get_the_excerpt().'</span>';
|
||||
}
|
||||
$output .= '</div>
|
||||
<div class="cat-clear"></div>
|
||||
</div>';
|
||||
};
|
||||
$output .= '</div>';
|
||||
$post = $tmp_post;
|
||||
wp_reset_query();
|
||||
return $output;
|
||||
}
|
||||
add_shortcode('cat', 'cat_func');
|
||||
|
||||
?>
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/*
|
||||
howto uninstall the pluggin
|
||||
https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/
|
||||
*/
|
||||
|
||||
// if uninstall.php is not called by WordPress, die
|
||||
if (!defined('WP_UNINSTALL_PLUGIN')) {
|
||||
die;
|
||||
}
|
||||
|
||||
$option_name = 'wporg_option';
|
||||
|
||||
delete_option($option_name);
|
||||
|
||||
// for site options in Multisite
|
||||
delete_site_option($option_name);
|
||||
|
||||
// drop a custom database table
|
||||
global $wpdb;
|
||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}mytable");
|
||||
|
||||
?>
|
Loading…
Reference in New Issue