Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/WebDevStudios/WP-carouFredSel
Simple plugin that will A) enqueue carouFredSel when requested, and B) (if requested) create a custom "featured" post type for the carousel
https://github.com/WebDevStudios/WP-carouFredSel
Last synced: 15 days ago
JSON representation
Simple plugin that will A) enqueue carouFredSel when requested, and B) (if requested) create a custom "featured" post type for the carousel
- Host: GitHub
- URL: https://github.com/WebDevStudios/WP-carouFredSel
- Owner: WebDevStudios
- Created: 2013-02-04T17:20:19.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-06-18T14:05:14.000Z (over 11 years ago)
- Last Synced: 2024-08-01T05:23:25.923Z (3 months ago)
- Language: JavaScript
- Size: 289 KB
- Stars: 7
- Watchers: 11
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
WP-carouFredSel
===============Simple plugin that will A) enqueue carouFredSel when requested, and B) (if requested) create a custom "featured" post type for the carousel
### To enqueue carouFredSel:
In your theme functions file or plugin, place the function
```php
wds_caroufredsel();
```### To configure a carouFredSel instance:
```php
wds_caroufredsel( '#element' );
```### To pass configuration parameters to the carouFredSel instance:
```php
$args = array(
'width' => 870,
'items' => 8,
'scroll' => 4
);
wds_caroufredsel( '#element', $args );
```### To enable a featured custom post type:
```php
wds_enable_cfs_cpt();
```### To grab data (wrapped in a transient) from the featured custom post type:
```php
wds_fcs_get_featured();
```### wds_fcs_get_featured() takes 3 arguments:
**$WP_Query_args:** pass any WP_Query arguments you want that aren't in the default
Default: array(
'post_type' => 'featured-entries',
'posts_per_page' => 5,
'post_status' => 'publish',
'no_found_rows' => true,
)**$return_full_query:** whether to return the query from WP_Query or a subset of the data (Title, link meta, content, and featured image)
Default: false (return the subset of data instead of the full query)**$use_transient:** Whether to wrap data in a transient to save on load time and queries to the database. The transient resets when a featured entry is saved in the admin.
Default: true (use transient)### To grab data (wrapped in a transient) from featured custom post type and then display it in a carouFredSel instance:
```php
// Assumes you have 'wds_enable_cfs_cpt();' in your themes functions file./**
* Enqueu carouFredSel and loop through our featured posts
*/
function dma_loop_featured() {
// make sure our plugin is activated
if ( !function_exists('wds_fcs_get_featured') )
return;
$featured = wds_fcs_get_featured();
// if our query is empty, bail here
if ( !$featured )
return;
?>
$feature ) {// feature's image
$html = wds_maybe_link( $feature, 'image' );
// feature's title
$html .= wds_maybe_link( $feature, 'title', 'h2' );
// feature's content
$html .= wds_maybe_link( $feature, 'content' );echo '
- '. $html .'
';
}
?>
572,
'items' => 1,
'scroll' => 1,
'scroll' => array(
'fx' => 'crossfade'
),
'auto' => array(
'easing' => 'linear',
'duration' => 1000,
'timeoutDuration' => 2000,
'pauseOnHover' => true
),
) );}
/**
* Wrap feature in url if it has one
*/
function wds_maybe_link( $feature, $index, $wrap = false ) {if ( !$index )
return '';if ( !$feature['url'] )
return $feature[$index];$html = ''. $feature[$index] .'';
if ( $wrap )
$html = '<'. $wrap .'>'. $html .''. $wrap .'>';return $html;
}
```