Skip to content

Commit

Permalink
v0.3-beta
Browse files Browse the repository at this point in the history
* Enhancement: added help link to Post screen option.
* Enhancement: added About document.
* Architecture: moved code for Post screen option to separate file.
* Architecture: moved inline CSS to separate file.
  • Loading branch information
glueckpress committed Feb 1, 2016
1 parent 57b1218 commit 2ab1d57
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 48 deletions.
30 changes: 30 additions & 0 deletions ABOUT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## DEWP-Planet-Feed

> @todo Needs review!
## Was ist der DEWP-Planet?
Der [DEWP-Planet](http://de.planetwp.org/) ist ein Feed-Aggregator. Sein Feed wird aus verschiedenen einzelnen Blog-Feeds gespeist. Seine Hauptaufgabe besteht darin, die Inhalte des __Dashboard-Wigdets WordPress-Nachrichten__ zu liefern:

![Dashboard-Widget „WordPress-Nachrichten“](https://github.com/deworg/dewp-planet-feed/blob/master/assets/img/wp-news-dashboard-widget.png?raw=true)

### Was macht die Option unter _Veröffentlichen_?
Mithilfe der Option __Im DEWP-Planet-Feed anzeigen__ kannst du in deinem Blog einzelne Beiträge einem speziellen RSS-Feed namens __dewp-planet__ zuweisen. Die URL dieses Feeds sieht etwa so aus:

```
http://example.com/feed/dewp-planet/
http://example.com?feed=dewp-planet
```

#### Bitte verwende die Option mit Bedacht!

__Sofern dein Feed Teil des DEWP-Planet-Feed ist, landet dein Beitrag direkt in den Dashboards aller deutschsprachigen WordPress-Installationen.__

__Nutze den Planet, um dein WordPress-Wissen frei zu teilen. Du bist selbst dafür verantwortlich, dass deine Inhalte der hervorgehobenen Position in den Dashboards einiger Tausend Nutzerinnen und Nutzer angemessen sind.__

## Landet mein Beitrag mit diesem Plugin automatisch im Dashboard anderer Nutzer_innen?
Nur wenn dein Feed bereits in den _Planet_ aufgenommen wurde. Dafür ist eine manuelle Freischaltung seitens des _Planet_ erforderlich.<br>__Allein die Verwendung dieses Plugins speist dein durch das Plugin neu erzeugte Feed noch _nicht_ in _Planet_-Feed für die Dashboard-Widgets ein.__

### Wie kommt mein Blog-Feed in den DEWP-Planet?
Die Betreueung des DEWP-Planets obliegt einem Team von Freiwilligen der [deutschsprachigen WordPress Community](https://de.wordpress.org/). Den Slack-Channel des Teams findest du hier: [dewp.slack.com/messages/planet/](https://dewp.slack.com/messages/planet/)

Das Team des Planet wird initiativ aktiv und fügt die Feeds geeigneter Blogs in regelmäßigen Abständen zum DEWP-Planet hinzu. Die Betreiber_innen der entsprechenden Blogs werden zuvor nach ihrem Einverstädnis gefragt. Auch behält sich das Team vor, jederzeit und ohne Angabe von Gründen einzelne Feeds aus dem _DEWP-Planet_ zu entfernen.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Generates a custom feed `dewp-planet` for posts. Adds a checkbox to the _Publish

## Changelog

### 0.3
* Enhancement: added help link to Post screen option.
* Enhancement: added About document.
* Architecture: moved code for Post screen option to separate file.
* Architecture: moved inline CSS to separate file.

### 0.2
* Enhancement: lower priority for publishing checkbox.
* Clean-up: Renamed plugin to __DEWP Planet Feed__ and PHP class to `DEWP_Planet_Feed`.
Expand Down
45 changes: 45 additions & 0 deletions assets/css/post.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* DEWP Planet Plugin
*/
.dewp-planet__add-to-feed {
margin: -4px 10px 0 0;
}
.dewp-planet__help-link {
margin: 0 0 0 -5px;
padding: 10px;
position: relative;
text-decoration: none;
/*vertical-align: middle;*/
}
/* Invisible states */
.dewp-planet__label-notice {
display: block;
max-height: 1px;
overflow: hidden;
-webkit-transition: padding 200ms linear;
-moz-transition: padding 200ms linear;
-ms-transition: padding 200ms linear;
-o-transition: padding 200ms linear;
transition: padding 200ms linear;
}
.dewp-planet__add-to-feed + .dewp-planet__label-text .dashicons-warning {
visibility: hidden;
}
/* Visibile states */
.dewp-planet__add-to-feed:checked + .dewp-planet__label-text .dashicons-warning {
margin: -1px 5px 0 -2px;
position: relative;
visibility: visible;
}
.dewp-planet__add-to-feed:checked + .dewp-planet__label-text .dewp-planet__label-notice {
max-height: 10em;
padding: 6px 0 8px;
}
/* Colors */
.dewp-planet__help-link,
.dewp-planet__add-to-feed:disabled + .dewp-planet__label-text {
color: #b4b9be;
}
.dewp-planet__add-to-feed:checked + .dewp-planet__label-text .dashicons-warning {
color: #dc3232;
}
Binary file added assets/img/wp-news-dashboard-widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 44 additions & 48 deletions dewp-planet-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Plugin Name: DEWP Planet Feed (Beta)
* Description: Generates a custom feed “dewp-planet” for posts. Adds a checkbox to the Publish meta box in order to explicitly add a post to that custom feed.
* Version: 0.2-beta2
* Version: 0.3-beta
* Author: dewp#planet team
* Author URI: https://dewp.slack.com/messages/planet/
* Plugin URI: https://github.com/deworg/dewp-planet-feed
Expand All @@ -27,6 +27,7 @@

/**
* Set marker for activation.
* @since 0.1
*/
register_activation_hook(
__FILE__,
Expand All @@ -35,6 +36,7 @@

/**
* Flush rewrite rules.
* @since 0.1
*/
register_deactivation_hook(
__FILE__,
Expand Down Expand Up @@ -93,7 +95,7 @@ public function __construct() {

/**
* Set marker for activation.
* @since 0.1
* @since 0.1
* @return void
*/
public static function activation() {
Expand All @@ -102,7 +104,7 @@ public static function activation() {

/**
* Flush rewrite rules and delete option on deactivation.
* @since 0.1
* @since 0.1
* @return void
*/
public static function deactivation() {
Expand All @@ -112,7 +114,7 @@ public static function deactivation() {

/**
* Initialize plugin.
* @since 0.1
* @since 0.1
* @return void
*/
public static function init() {
Expand All @@ -129,13 +131,19 @@ public static function init() {
add_action( 'post_submitbox_misc_actions', array( __CLASS__, 'add_checkbox' ), 9 );
add_action( 'save_post', array( __CLASS__, 'save_checkbox' ) );

// Enqueue admin scripts and styles.
add_action(
'admin_enqueue_scripts',
array( __CLASS__, 'admin_enqueue_scripts' )
);

// Get feed content.
add_action( 'pre_get_posts', array( __CLASS__, 'feed_content' ) );
}

/**
* Load feed template.
* @since 0.1
* @since 0.1
* @return void
*/
public static function feed_template() {
Expand All @@ -144,7 +152,7 @@ public static function feed_template() {

/**
* Add checkbox to Publish Post meta box.
* @since 0.1
* @since 0.1
* @return void
*/
public static function add_checkbox() {
Expand All @@ -161,53 +169,40 @@ public static function add_checkbox() {
// This actually defines whether post will be listed in our feed.
$value = get_post_meta( $post->ID, '_wpf_show_in_dewp_planet_feed', true );

/**
* Filterable label text for checkbox. (Skipped i18n for now.)
* @since 0.1
*/
$label_text = apply_filters(
'wp_planet_feed__checkbox_label',
sprintf(
'<span class="wp-panet-feed__label-text">%1$s <span class="dashicons dashicons-warning" aria-hidden="true"></span><span class="screen-reader-text"><strong>%2$s</strong></span></span>',
'Im DEWP-Planet anzeigen',
'Erscheint in allen deutschsprachigen WordPress-Dashboards!'
)
ob_start();
include trailingslashit( dirname( __FILE__ ) ) . 'inc/pub-section.php';
$pub_section = ob_get_clean();

echo $pub_section;
}

/**
* Register and enqueue admin scripts and styles.
* @since 0.3
* @param string $hook Current admin page
* @return return Current admin page
*/
public static function admin_enqueue_scripts( $hook ) {
if ( 'post.php' !== $hook && 'post-new.php' !== $hook )
return;

$file_data = get_file_data( __FILE__, array( 'v' => 'Version' ) );
$assets_url = trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/';

// CSS
wp_register_style(
'dewp-planet-post', $assets_url . 'css/post.css',
array( 'edit' ),
$file_data['v']
);
wp_enqueue_style( 'dewp-planet-post' );

// Scoped inline styles for now, sue me. WP Core colors FTW.
?>
<div class="misc-pub-section wp-planet-feed">
<style type="text/css" scope>
input.wpf-show-in-dewp-planet-feed {
margin: -4px 10px 0 0;
}
input.wpf-show-in-dewp-planet-feed + span.wp-panet-feed__label-text span.dashicons-warning,
input.wpf-show-in-dewp-planet-feed:disabled + span.wp-panet-feed__label-text,
input.wpf-show-in-dewp-planet-feed:disabled + span.wp-panet-feed__label-text span.dashicons-warning {
color: #b4b9be;
}
input.wpf-show-in-dewp-planet-feed:checked + span.wp-panet-feed__label-text span.dashicons-warning {
color: #dc3232;
}
input.wpf-show-in-dewp-planet-feed:checked + span.wp-panet-feed__label-text span.screen-reader-text {
display: block;
height: auto;
padding: 6px 0 8px;
position: static;
width: auto;
}
</style>
<label for="wpf-show-in-dewp-planet-feed">
<input type="checkbox" id="wpf-show-in-dewp-planet-feed" name="wpf-show-in-dewp-planet-feed" class="wpf-show-in-dewp-planet-feed" <?php checked( $value ); disabled( $maybe_enabled, false ); ?> value="1" />
<?php print $label_text; ?>
</label>
</div>
<?php
return $hook;
}

/**
* Save option value to post meta.
* @since 0.1
* @since 0.1
* @param integer $post_id ID of current post
* @return integer ID of current post
*/
Expand All @@ -228,7 +223,7 @@ public static function save_checkbox( $post_id ) {
if ( ! current_user_can( self::$capability ) ) {
return $post_id;
}
if ( empty( $_POST['wpf-show-in-dewp-planet-feed'] ) ) {
if ( empty( $_POST['dewp-planet__add-to-feed'] ) ) {
delete_post_meta( $post_id, '_wpf_show_in_dewp_planet_feed' );
} else {
add_post_meta( $post_id, '_wpf_show_in_dewp_planet_feed', 1, true );
Expand All @@ -239,6 +234,7 @@ public static function save_checkbox( $post_id ) {

/**
* Set feed content.
* @since 0.1
* @param object $query WP_Query object
* @return object Altered WP_Query object
*/
Expand Down
38 changes: 38 additions & 0 deletions inc/pub-section.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Publish box template
* @since 0.3
*/

/**
* Filterable label text for checkbox. (Skipped i18n for now.)
* @since 0.3
*/
$label_text = apply_filters(
'dewp_planet__pub_section_label',
'Im DEWP-Planet-Feed anzeigen'
);

/**
* Filterable notice text for checkbox. (Skipped i18n for now.)
* @since 0.3
*/
$notice_text = apply_filters(
'dewp_planet__pub_section_notice',
'<span class="dashicons dashicons-warning" aria-hidden="true"></span><strong>Erscheint in allen deutschsprachigen WordPress-Dashboards!</strong>'
);
?>
<div class="misc-pub-section dewp-planet">
<label for="dewp-planet__add-to-feed">
<input type="checkbox" id="dewp-planet__add-to-feed" name="dewp-planet__add-to-feed" class="dewp-planet__add-to-feed" <?php checked( $value ); disabled( $maybe_enabled, false ); ?> value="1" />
<span class="dewp-planet__label-text">
<?php echo $label_text; ?>
<a href="https://github.com/deworg/dewp-planet-feed/blob/master/ABOUT.md" class="dewp-planet__help-link dashicons-before dashicons-editor-help hide-if-no-js" target="_blank">
<span class="screen-reader-text">Was ist das?</span>
</a>
<span class="dewp-planet__label-notice">
<?php echo $notice_text; ?>
</span>
</span>
</label>
</div>

0 comments on commit 2ab1d57

Please sign in to comment.