| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/post-grid.tar |
editor.scss 0000666 00000004445 15114217727 0006751 0 ustar 00 .wp-block-themeisle-blocks-posts-grid {
display: flex;
flex-wrap: wrap;
&.is-grid {
.grid-post {
.grid-post-row {
.grid-image-area {
flex: 0 0 100%;
max-width: 100%;
}
.grid-content-area {
flex: 0 0 100%;
max-width: 100%;
.grid-content-category {
margin: 10px 0;
}
}
}
&.grid-2 {
flex: 0 0 50%;
max-width: 50%;
padding: 0 15px;
}
&.grid-3 {
flex: 0 0 33%;
max-width: 33%;
padding: 0 15px;
}
&.grid-4 {
flex: 0 0 25%;
max-width: 25%;
padding: 0 15px;
}
&.grid-5 {
flex: 0 0 20%;
max-width: 20%;
padding: 0 15px;
}
}
}
.grid-post {
margin: 20px 0;
background: transparent;
box-shadow: none;
border: 0;
border-radius: 6px;
color: rgba(0,0,0,.87);
width: 100%;
.grid-post-row {
display: flex;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
.grid-image-area {
flex: 0 0 33.333333%;
max-width: 33.333333%;
position: relative;
width: 100%;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
.post-thumbnail {
position: relative;
padding: 0;
z-index: 1;
border-radius: 6px;
img {
width: 100%;
border-radius: 6px;
box-shadow: 0 5px 15px 5px rgba(0,0,0,.24),0 8px 10px -5px rgba(0,0,0,.2);
}
}
}
.grid-content-area {
flex: 0 0 66.666667%;
max-width: 66.666667%;
position: relative;
width: 100%;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
&.full {
flex: 0 0 100%;
max-width: 100%;
}
.grid-content-category {
font-size: 11px;
font-weight: bold;
margin: 0;
a {
color: #000000;
text-decoration: none;
}
}
.grid-content-title {
font-size: 16px;
font-weight: bold;
margin: 0;
a {
text-decoration: none;
}
}
.grid-content-meta {
margin: 0;
font-size: 14px;
a {
color: #000000;
}
}
.grid-content-excerpt {
line-height: 1.5;
margin: 1em 0;
}
}
}
}
}
@media ( max-width:600px ) {
.wp-block-themeisle-blocks-posts-grid {
&.is-grid {
.grid-post {
flex: 0 0 100% !important;
max-width: 100% !important;
padding: 0 !important;
}
}
}
} index.js 0000666 00000020051 15114217727 0006222 0 ustar 00 /**
* External dependencies
*/
import classnames from 'classnames';
import Thumbnail from './Thumbnail.js';
/**
* WordPress dependencies...
*/
const { isUndefined, pickBy } = lodash;
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const {
Button,
Dashicon,
PanelBody,
QueryControls,
RangeControl,
Spinner,
TextControl,
ToggleControl,
Toolbar,
Tooltip
} = wp.components;
const { withSelect } = wp.data;
const {
BlockControls,
InspectorControls
} = wp.editor;
const unescapeHTML = value => {
const htmlNode = document.createElement( 'div' );
htmlNode.innerHTML = value;
if ( htmlNode.innerText !== undefined ) {
return htmlNode.innerText;
}
return htmlNode.textContent;
};
const formatDate = date => {
const monthNames = [
__( 'January' ), __( 'February' ), __( 'March' ),
__( 'April' ), __( 'May' ), __( 'June' ), __( 'July' ),
__( 'August' ), __( 'September' ), __( 'October' ),
__( 'November' ), __( 'December' )
];
const weekNames = [
__( 'Sunday' ), __( 'Monday' ), __( 'Tuesday' ), __( 'Wednesday' ),
__( 'Thursday' ), __( 'Friday' ), __( 'Saturday' )
];
date = new Date( date );
const day = date.getDate();
const monthIndex = date.getMonth();
const year = date.getFullYear();
return day + ' ' + monthNames[monthIndex] + ', ' + year;
};
import './style.scss';
import './editor.scss';
registerBlockType( 'themeisle-blocks/posts-grid', {
title: __( 'Posts Grid' ),
description: __( 'Display a list of your most recent posts in a beautiful grid.' ),
icon: 'screenoptions',
category: 'themeisle-blocks',
keywords: [
'posts',
'grid',
'orbitfox'
],
attributes: {
grid: {
type: 'boolean',
default: false
},
columns: {
type: 'number',
default: 3
},
categories: {
type: 'string'
},
postsToShow: {
type: 'number',
default: 5
},
order: {
type: 'string',
default: 'desc'
},
orderBy: {
type: 'string',
default: 'date'
},
displayFeaturedImage: {
type: 'boolean',
default: true
},
displayCategory: {
type: 'boolean',
default: true
},
displayDate: {
type: 'boolean',
default: true
},
displayAuthor: {
type: 'boolean',
default: true
},
excerptLength: {
type: 'number',
default: 200
}
},
edit: withSelect( ( select, props ) => {
const { categories, order, orderBy, postsToShow } = props.attributes;
const latestPostsQuery = pickBy({
categories,
order,
orderby: orderBy,
per_page: postsToShow // eslint-disable-line camelcase
}, ( value ) => ! isUndefined( value ) );
return {
posts: select( 'core' ).getEntityRecords( 'postType', 'post', latestPostsQuery ),
// eslint-disable-next-line camelcase
categoriesList: select( 'core' ).getEntityRecords( 'taxonomy', 'category', { per_page: 100 }),
authors: select( 'core' ).getAuthors(),
props
};
})( ({ posts, categoriesList, authors, className, setAttributes, props }) => {
if ( ! posts ) {
return (
<p className={ className } >
<Spinner />
{ __( 'Loading Posts' ) }
</p>
);
}
if ( 0 === posts.length ) {
return <p>{ __( 'No Posts' ) }</p>;
}
const {
grid,
columns,
order,
orderBy,
categories,
postsToShow,
displayFeaturedImage,
displayCategory,
displayDate,
displayAuthor,
excerptLength
} = props.attributes;
const toggleLayout = () => {
props.setAttributes({ grid: ! grid });
};
const changeColumns = value => {
props.setAttributes({ columns: value});
};
const toggleFeaturedImage = () => {
props.setAttributes({ displayFeaturedImage: ! displayFeaturedImage });
};
const toggleDisplayCategory = () => {
props.setAttributes({ displayCategory: ! displayCategory });
};
const toggleDisplayDate = () => {
props.setAttributes({ displayDate: ! displayDate });
};
const toggleDisplayAuthor = () => {
props.setAttributes({ displayAuthor: ! displayAuthor });
};
const onExcerptLength = value => {
props.setAttributes({ excerptLength: value });
};
return [
<BlockControls key="toolbar-controls">
<Toolbar
className='components-toolbar'
>
<Tooltip text={ __( 'List Layout' ) }>
<Button
className={ classnames(
'components-icon-button',
'components-toolbar__control',
{ 'is-active': ! grid },
) }
onClick={ toggleLayout }
>
<Dashicon icon="list-view" />
</Button>
</Tooltip>
<Tooltip text={ __( 'Grid Layout' ) }>
<Button
className={ classnames(
'components-icon-button',
'components-toolbar__control',
{ 'is-active': grid },
) }
onClick={ toggleLayout }
>
<Dashicon icon="grid-view" />
</Button>
</Tooltip>
</Toolbar>
</BlockControls>,
<InspectorControls>
<PanelBody
title={ __( 'Posts Grid Settings' ) }
>
{ ( grid ) && (
<RangeControl
label={ __( 'Columns' ) }
value={ columns }
onChange={ changeColumns}
min={ 1 }
max={ 5 }
>
</RangeControl>
) }
<QueryControls
{ ...{ order, orderBy } }
numberOfItems={ postsToShow }
categoriesList={ categoriesList }
selectedCategoryId={ categories }
onOrderChange={ ( value ) => setAttributes({ order: value }) }
onOrderByChange={ ( value ) => setAttributes({ orderBy: value }) }
onCategoryChange={ ( value ) => setAttributes({ categories: '' !== value ? value : undefined }) }
onNumberOfItemsChange={ ( value ) => setAttributes({ postsToShow: value }) }
/>
<ToggleControl
label={ __( 'Display Featured Image?' ) }
checked={ displayFeaturedImage }
onChange={ toggleFeaturedImage }
/>
<ToggleControl
label={ __( 'Display Post Category?' ) }
checked={ displayCategory }
onChange={ toggleDisplayCategory }
/>
<ToggleControl
label={ __( 'Display Post Date?' ) }
checked={ displayDate }
onChange={ toggleDisplayDate }
/>
<ToggleControl
label={ __( 'Display Post Author?' ) }
checked={ displayAuthor }
onChange={ toggleDisplayAuthor }
/>
<TextControl
label={ __( 'Description Character Limit' ) }
type="number"
value={ excerptLength }
onChange={ onExcerptLength }
/>
</PanelBody>
</InspectorControls>,
<div className={ classnames(
className,
{ 'is-grid': grid },
) }>
{ posts.map( post => {
let category, author;
if ( categoriesList ) {
category = categoriesList.find( item => item.id === post.categories[0]);
}
if ( authors ) {
author = authors.find( item => item.id === post.author );
}
return (
<div className={ `grid-post grid-${ columns }` }>
<div className="grid-post-row">
{ ( 0 !== post.featured_media && displayFeaturedImage ) &&
<div className="grid-image-area" >
<Thumbnail id={ post.featured_media } link={ post.link } />
</div>
}
<div className={ `grid-content-area ${ ! displayFeaturedImage && 'full' }` }>
{ ( displayCategory && categoriesList ) && (
<h6 className="grid-content-category">
<a href={ category.link }>{ category.name }</a>
</h6>
) }
<h3 className="grid-content-title">
<a href={ post.link }>
{ post.title.rendered }
</a>
</h3>
{ ( displayDate || displayAuthor ) && (
<p className="grid-content-meta">
{ ( displayDate ) && [
__( 'on ' ),
<time datetime={ post.date }>{ formatDate( post.date ) }</time>,
' '
] }
{ ( displayAuthor && authors ) && [
__( 'by ' ),
<a href={ author.link }>{ author.name }</a>
] }
</p>
) }
{ ( 0 < excerptLength ) && (
<p className="grid-content-excerpt">
{ unescapeHTML( post.excerpt.rendered ).substring( 0, excerptLength ) + '…' }
</p>
) }
</div>
</div>
</div>
);
}) }
</div>
];
}),
save: () => {
return null;
}
});
.htaccess 0000666 00000000424 15114217727 0006355 0 ustar 00 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>