-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0655e7f
Showing
10 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.git | ||
/.github | ||
/.wordpress-org | ||
|
||
.distignore | ||
.gitignore | ||
.gitattributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Directories | ||
/.wordpress-org export-ignore | ||
/.github export-ignore | ||
|
||
# Files | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# https://github.com/10up/action-wordpress-plugin-asset-update | ||
|
||
# This Action commits any readme and WordPress.org-specific assets changes in your specified branch to the | ||
# WordPress.org plugin repository if no other changes have been made since the last deployment to WordPress.org. | ||
# This is useful for updating things like screenshots or Tested up to separately from functional changes, provided | ||
# your Git branching methodology avoids changing anything else in the specified branch between functional releases. | ||
|
||
name: Plugin asset/readme update | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
master: | ||
name: Update plugin and assets | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: WordPress.org plugin asset/readme update | ||
uses: 10up/action-wordpress-plugin-asset-update@master | ||
env: | ||
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} # Set in repo -> Settings -> Secrets | ||
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} # Set in repo -> Settings -> Secrets | ||
README_NAME: README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://github.com/10up/action-wordpress-plugin-deploy | ||
|
||
# This Action commits the contents of your Git tag to the WordPress.org plugin repository using the same tag name. | ||
# It can exclude files as defined in either .distignore or .gitattributes, and moves anything from a .wordpress-org | ||
# subdirectory to the top-level assets directory in Subversion (plugin banners, icons, and screenshots). | ||
|
||
name: Publish plugin to WordPress.org | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
jobs: | ||
tag: | ||
name: New tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: WordPress Plugin Deploy | ||
uses: 10up/action-wordpress-plugin-deploy@master | ||
env: | ||
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | ||
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | ||
SLUG: no-login # Change this |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?php | ||
/** | ||
* Plugin Name: FartScroll | ||
* Plugin URI: http://planetozh.com/blog/my-projects/wordpress-plugin-fart-scroll-theonion/ | ||
* GitHub Plugin URI: https://github.com/ozh/fartscroll | ||
* Description: "You want fart noises as you scroll? We've got you covered." A WordPress implementation of TheOnion's <a href="http://theonion.github.io/fartscroll.js/">Fartscroll.js</a> elegant piece of software | ||
* Version: 1.0.1 | ||
* Requires at least: 3.0 | ||
* Requires PHP: 5.6 | ||
* Author: Ozh & TheOnion | ||
* Author URI: http://ozh.org/ | ||
*/ | ||
|
||
|
||
/****************** Public stuff */ | ||
|
||
// Add JS to pages of the blog | ||
add_action( 'template_redirect', 'fartscroll_add_script' ); | ||
function fartscroll_add_script() { | ||
$options = get_option( 'fartscroll_options' ); | ||
$fart_chance = ( isset( $options['fart_chance'] ) ? $options['fart_chance'] : 100 ); | ||
if( mt_rand( 0, 100 ) <= $fart_chance ) { | ||
wp_enqueue_script( 'fartscroll', plugin_dir_url( __FILE__) . 'fartscroll.js' ); | ||
add_action( 'wp_footer', 'fartscroll_add_footer' ); | ||
} | ||
} | ||
|
||
// Add JS to footer | ||
function fartscroll_add_footer() { | ||
$options = get_option( 'fartscroll_options' ); | ||
$fart_scroll = ( isset( $options['fart_scroll'] ) ? $options['fart_scroll'] : 800 ); | ||
echo <<<FART | ||
<script type="text/javascript"> | ||
fartscroll( $fart_scroll ); | ||
</script> | ||
FART; | ||
} | ||
|
||
|
||
/****************** Admin stuff */ | ||
|
||
// Add a menu for our option page | ||
add_action('admin_menu', 'fartscroll_add_page'); | ||
function fartscroll_add_page() { | ||
add_options_page( 'Fartscroll', 'Fartscroll', 'manage_options', 'fartscroll', 'fartscroll_option_page' ); | ||
} | ||
|
||
// Draw the option page | ||
function fartscroll_option_page() { | ||
?> | ||
<div class="wrap"> | ||
<?php screen_icon(); ?> | ||
<h2>Fartscroll. Pfffrrrtf.</h2> | ||
<form action="options.php" method="post"> | ||
<?php settings_fields('fartscroll_options'); ?> | ||
<?php do_settings_sections('fartscroll'); ?> | ||
<input name="Submit" type="submit" value="Save Changes" /> | ||
</form> | ||
</div> | ||
<?php | ||
} | ||
|
||
// Register and define the settings | ||
add_action('admin_init', 'fartscroll_admin_init'); | ||
function fartscroll_admin_init(){ | ||
register_setting( | ||
'fartscroll_options', | ||
'fartscroll_options', | ||
'fartscroll_validate_options' | ||
); | ||
add_settings_section( | ||
'fartscroll_main', | ||
'Fartscroll Settings', | ||
'fartscroll_section_text', | ||
'fartscroll' | ||
); | ||
add_settings_field( | ||
'fartscroll_fart_scroll', | ||
'Scrolling', | ||
'fartscroll_setting_input_scroll', | ||
'fartscroll', | ||
'fartscroll_main' | ||
); | ||
add_settings_field( | ||
'fartscroll_fart_chance', | ||
'Probability', | ||
'fartscroll_setting_input_chance', | ||
'fartscroll', | ||
'fartscroll_main' | ||
); | ||
} | ||
|
||
// Draw the section header | ||
function fartscroll_section_text() { | ||
echo '<p>Configure how much and how often you want farts on scrolls.</p>'; | ||
} | ||
|
||
// Display and fill the form field | ||
function fartscroll_setting_input_scroll() { | ||
// get option 'fart_scroll' value from the database | ||
$options = get_option( 'fartscroll_options' ); | ||
$fart_scroll = ( isset( $options['fart_scroll'] ) ? $options['fart_scroll'] : 800 ); | ||
// echo the field | ||
echo "<input id='fart_scroll' name='fartscroll_options[fart_scroll]' type='text' value='$fart_scroll' />"; | ||
echo "<br/>How many pixels scrolled to emit a fart ? (default: 800)"; | ||
} | ||
|
||
// Display and fill the form field | ||
function fartscroll_setting_input_chance() { | ||
// get option 'fart_chance' value from the database | ||
$options = get_option( 'fartscroll_options' ); | ||
$fart_chance = ( isset( $options['fart_chance'] ) ? $options['fart_chance'] : 100 ); | ||
// echo the field | ||
echo "<input id='fart_chance' name='fartscroll_options[fart_chance]' type='text' value='$fart_chance' />"; | ||
echo "<br/>Probability, in percent, that the script is loaded on a page. 100 = all pages, 10 = 1 page out of ten (default: 100)"; | ||
} | ||
|
||
// Validate user input | ||
function fartscroll_validate_options( $input ) { | ||
$valid = array(); | ||
$valid['fart_scroll'] = intval( $input['fart_scroll'] ); | ||
$valid['fart_chance'] = min( absint( $input['fart_chance'] ), 100 ); | ||
|
||
return $valid; | ||
} | ||
|
||
// Settings link in plugin management screen | ||
function fartscroll_settings_link($actions, $file) { | ||
if( false !== strpos($file, 'fartscroll' ) ) | ||
$actions['settings'] = '<a href="options-general.php?page=fartscroll">Fart settings</a>'; | ||
return $actions; | ||
} | ||
add_filter( 'plugin_action_links', 'fartscroll_settings_link', 2, 2 ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Fartscroll | ||
|
||
"You want fart noises as you scroll? We've got you covered." | ||
|
||
A WordPress implementation of TheOnion's [Fartscroll.js](http://theonion.github.io/fartscroll.js/) most elegant piece of software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
=== Fartscroll === | ||
Tags: fart, scroll, fartscroll, theonion, smell, prank, ozh | ||
Donate link: http://planetozh.com/exit/donate | ||
Requires at least: 3.0 | ||
Tested up to: 5.4.1 | ||
Requires PHP: 5.6 | ||
Stable tag: trunk | ||
Contributors: ozh | ||
|
||
You want fart noises as you scroll? We've got you covered | ||
|
||
== Description == | ||
|
||
"You want fart noises as you scroll? We've got you covered." | ||
|
||
A WordPress implementation of TheOnion's [Fartscroll.js](http://theonion.github.io/fartscroll.js/) most elegant piece of software | ||
|
||
== Installation == | ||
|
||
1. Unzip & upload the plugin directory inside your `/wp-content/plugins/` directory | ||
1. Activate the plugin through the 'Plugins' menu in WordPress | ||
1. Scroll blog pages |